1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-31 08:35:25 +02:00
parent de946967d7
commit 7ecdc5330d

View file

@ -128,30 +128,40 @@ local function toggleAnchor(vehicle)
local coords = GetEntityCoords(vehicle) local coords = GetEntityCoords(vehicle)
local heading = GetEntityHeading(vehicle) local heading = GetEntityHeading(vehicle)
-- Finde die Wasseroberfläche unter dem Boot -- Finde die Wasseroberfläche unter dem Boot
local waterHeight = GetWaterHeightNoWaves(coords.x, coords.y, coords.z) local waterHeight = GetWaterHeightNoWaves(coords.x, coords.y, coords.z)
-- Wenn Wasser gefunden wurde, setze das Boot auf die Wasseroberfläche -- Wenn kein Wasser gefunden wurde, nutze eine alternative Methode
if waterHeight ~= 0 then if waterHeight == 0 then
SetEntityCoords(vehicle, coords.x, coords.y, waterHeight) -- Versuche mit TestVerticalProbeAgainstAllWater
coords = GetEntityCoords(vehicle) -- Aktualisiere Koordinaten nach Positionsänderung local success, height = TestVerticalProbeAgainstAllWater(coords.x, coords.y, coords.z, 0, coords.z - 10.0)
end if success then
waterHeight = height
else
-- Fallback: Setze Boot leicht unter aktuelle Position
waterHeight = coords.z - 0.5
end
end
FreezeEntityPosition(vehicle, true) -- Setze das Boot auf die Wasseroberfläche mit leichtem Offset
SetEntityInvincible(vehicle, true) SetEntityCoords(vehicle, coords.x, coords.y, waterHeight)
coords = GetEntityCoords(vehicle) -- Aktualisiere Koordinaten nach Positionsänderung
local anchorData = { FreezeEntityPosition(vehicle, true)
coords = coords, SetEntityInvincible(vehicle, true)
heading = heading,
time = GetGameTimer()
}
anchoredBoats[vehicleNetId] = anchorData local anchorData = {
coords = coords,
heading = heading,
time = GetGameTimer()
}
-- Speichere auf Server anchoredBoats[vehicleNetId] = anchorData
saveAnchorToServer(vehicle, anchorData)
QBCore.Functions.Notify('⚓ Anker geworfen! Das Boot ist jetzt verankert.', 'success') -- Speichere auf Server
saveAnchorToServer(vehicle, anchorData)
QBCore.Functions.Notify('⚓ Anker geworfen! Das Boot ist jetzt verankert.', 'success')
end end
end end