forked from Simnation/Main
ed
This commit is contained in:
parent
e85c9f4335
commit
fc42940c2a
5 changed files with 71 additions and 5 deletions
BIN
resources/[inventory]/cs_shops/ui/image/dynamite.png
Normal file
BIN
resources/[inventory]/cs_shops/ui/image/dynamite.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
BIN
resources/[inventory]/inventory_images/images/dynamite.png
Normal file
BIN
resources/[inventory]/inventory_images/images/dynamite.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
|
@ -10368,7 +10368,17 @@ itemsData = {
|
||||||
image = 'rare_earth_magnet.png',
|
image = 'rare_earth_magnet.png',
|
||||||
name = 'rare_earth_magnet',
|
name = 'rare_earth_magnet',
|
||||||
},
|
},
|
||||||
|
dynamite = {
|
||||||
|
shouldClose = true,
|
||||||
|
type = 'item',
|
||||||
|
description = '',
|
||||||
|
weight = 400,
|
||||||
|
label = 'Stange Dynamit',
|
||||||
|
unique = true,
|
||||||
|
useable = true,
|
||||||
|
image = 'dynamite.png',
|
||||||
|
name = 'dynamite',
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,55 @@
|
||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
local isActive = false
|
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
|
-- Hauptfunktion
|
||||||
local function StartDynamiteFishing()
|
local function StartDynamiteFishing()
|
||||||
local ped = PlayerPedId()
|
local ped = PlayerPedId()
|
||||||
|
|
||||||
-- Prüfungen
|
-- Prüfungen
|
||||||
if isActive or not IsEntityInWater(ped) then
|
if isActive then
|
||||||
return QBCore.Functions.Notify('Nicht möglich!', 'error')
|
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
|
end
|
||||||
|
|
||||||
isActive = true
|
isActive = true
|
||||||
|
@ -39,7 +81,16 @@ local function StartDynamiteFishing()
|
||||||
disableCarMovement = true
|
disableCarMovement = true
|
||||||
}, {}, {}, {}, function()
|
}, {}, {}, {}, function()
|
||||||
local coords = GetEntityCoords(ped)
|
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
|
-- PS-DISPATCH ALERT
|
||||||
if Config.Police.enable and math.random(1, 100) <= Config.Police.alertChance then
|
if Config.Police.enable and math.random(1, 100) <= Config.Police.alertChance then
|
||||||
|
@ -64,6 +115,11 @@ local function StartDynamiteFishing()
|
||||||
end, Config.RequiredItem)
|
end, Config.RequiredItem)
|
||||||
end
|
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
|
-- Befehl registrieren
|
||||||
RegisterCommand('dynamitefish', StartDynamiteFishing)
|
RegisterCommand('dynamitefish', StartDynamiteFishing)
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ Config.Police = {
|
||||||
alertChance = 80, -- % Chance für Alarm
|
alertChance = 80, -- % Chance für Alarm
|
||||||
message = "Illegales Dynamitfischen gemeldet",
|
message = "Illegales Dynamitfischen gemeldet",
|
||||||
codeName = "dynamitefishing",
|
codeName = "dynamitefishing",
|
||||||
code = "10-66",
|
code = "10-67",
|
||||||
icon = "fas fa-fish",
|
icon = "fas fa-fish",
|
||||||
priority = 2
|
priority = 2
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue