1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-11 23:33:02 +02:00
parent e85c9f4335
commit fc42940c2a
5 changed files with 71 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View file

@ -10368,7 +10368,17 @@ itemsData = {
image = 'rare_earth_magnet.png',
name = 'rare_earth_magnet',
},
dynamite = {
shouldClose = true,
type = 'item',
description = '',
weight = 400,
label = 'Stange Dynamit',
unique = true,
useable = true,
image = 'dynamite.png',
name = 'dynamite',
},
}

View file

@ -1,13 +1,55 @@
local QBCore = exports['qb-core']:GetCoreObject()
local isActive = false
-- Funktion zum Prüfen, ob der Spieler in Richtung Wasser schaut
local function IsPlayerFacingWater()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
-- Berechne Punkt in Blickrichtung (5 Einheiten vor dem Spieler)
local radians = math.rad(heading)
local forwardX = coords.x + 5.0 * math.sin(-radians)
local forwardY = coords.y + 5.0 * math.cos(-radians)
-- Prüfe Wasserhöhe an dieser Position
local waterZ = 0.0
local success, waterHeight = GetWaterHeight(forwardX, forwardY, coords.z, waterZ)
-- Wenn GetWaterHeight erfolgreich ist und Wasser in Sichtlinie ist
if success then
-- Prüfe, ob Wasser in angemessener Höhe ist (nicht zu weit unten oder oben)
local heightDiff = math.abs(waterHeight - coords.z)
return heightDiff < 5.0 -- Wasser ist maximal 5 Einheiten über/unter dem Spieler
end
-- Alternative Methode: Teste mehrere Punkte vor dem Spieler
for distance = 1.0, 10.0, 1.0 do
local checkX = coords.x + distance * math.sin(-radians)
local checkY = coords.y + distance * math.cos(-radians)
local checkZ = coords.z - 1.0 -- Etwas unter Augenhöhe
-- Prüfe, ob dieser Punkt im Wasser ist
if IsPointInWater(checkX, checkY, checkZ) then
return true
end
end
return false
end
-- Hauptfunktion
local function StartDynamiteFishing()
local ped = PlayerPedId()
-- Prüfungen
if isActive or not IsEntityInWater(ped) then
return QBCore.Functions.Notify('Nicht möglich!', 'error')
if isActive then
return QBCore.Functions.Notify('Du bist bereits beim Fischen!', 'error')
end
-- Prüfe, ob Spieler in Richtung Wasser schaut
if not IsPlayerFacingWater() then
return QBCore.Functions.Notify('Du musst in Richtung Wasser schauen!', 'error')
end
isActive = true
@ -39,7 +81,16 @@ local function StartDynamiteFishing()
disableCarMovement = true
}, {}, {}, {}, function()
local coords = GetEntityCoords(ped)
AddExplosion(coords.x, coords.y, coords.z, Config.Explosion.type, Config.Explosion.volume, true, false, Config.Explosion.cameraShake)
-- Berechne Position für Explosion (etwas vor dem Spieler im Wasser)
local heading = GetEntityHeading(ped)
local radians = math.rad(heading)
local explosionX = coords.x + 8.0 * math.sin(-radians)
local explosionY = coords.y + 8.0 * math.cos(-radians)
local explosionZ = coords.z - 1.0 -- Etwas unter der Wasseroberfläche
-- Explosion im Wasser erzeugen
AddExplosion(explosionX, explosionY, explosionZ, Config.Explosion.type, Config.Explosion.volume, true, false, Config.Explosion.cameraShake)
-- PS-DISPATCH ALERT
if Config.Police.enable and math.random(1, 100) <= Config.Police.alertChance then
@ -64,6 +115,11 @@ local function StartDynamiteFishing()
end, Config.RequiredItem)
end
-- Hilfsfunktion: Prüft, ob ein Punkt im Wasser ist
function IsPointInWater(x, y, z)
return TestProbeAgainstWater(x, y, z, x, y, z - 10.0)
end
-- Befehl registrieren
RegisterCommand('dynamitefish', StartDynamiteFishing)

View file

@ -36,7 +36,7 @@ Config.Police = {
alertChance = 80, -- % Chance für Alarm
message = "Illegales Dynamitfischen gemeldet",
codeName = "dynamitefishing",
code = "10-66",
code = "10-67",
icon = "fas fa-fish",
priority = 2
}