From 7ecdc5330d86937689db193287b37298019d8cbd Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Thu, 31 Jul 2025 08:35:25 +0200 Subject: [PATCH] e --- .../[carscripts]/nordi_seats/client/main.lua | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/resources/[carscripts]/nordi_seats/client/main.lua b/resources/[carscripts]/nordi_seats/client/main.lua index ea288cd2f..6d1f392ab 100644 --- a/resources/[carscripts]/nordi_seats/client/main.lua +++ b/resources/[carscripts]/nordi_seats/client/main.lua @@ -128,30 +128,40 @@ local function toggleAnchor(vehicle) local coords = GetEntityCoords(vehicle) local heading = GetEntityHeading(vehicle) - -- Finde die Wasseroberfläche unter dem Boot - local waterHeight = GetWaterHeightNoWaves(coords.x, coords.y, coords.z) - - -- Wenn Wasser gefunden wurde, setze das Boot auf die Wasseroberfläche - if waterHeight ~= 0 then - SetEntityCoords(vehicle, coords.x, coords.y, waterHeight) - coords = GetEntityCoords(vehicle) -- Aktualisiere Koordinaten nach Positionsänderung - end - - FreezeEntityPosition(vehicle, true) - SetEntityInvincible(vehicle, true) - - local anchorData = { - coords = coords, - heading = heading, - time = GetGameTimer() - } - - anchoredBoats[vehicleNetId] = anchorData - - -- Speichere auf Server - saveAnchorToServer(vehicle, anchorData) - - QBCore.Functions.Notify('⚓ Anker geworfen! Das Boot ist jetzt verankert.', 'success') +-- Finde die Wasseroberfläche unter dem Boot +local waterHeight = GetWaterHeightNoWaves(coords.x, coords.y, coords.z) + +-- Wenn kein Wasser gefunden wurde, nutze eine alternative Methode +if waterHeight == 0 then + -- Versuche mit TestVerticalProbeAgainstAllWater + local success, height = TestVerticalProbeAgainstAllWater(coords.x, coords.y, coords.z, 0, coords.z - 10.0) + if success then + waterHeight = height + else + -- Fallback: Setze Boot leicht unter aktuelle Position + waterHeight = coords.z - 0.5 + end +end + +-- Setze das Boot auf die Wasseroberfläche mit leichtem Offset +SetEntityCoords(vehicle, coords.x, coords.y, waterHeight) +coords = GetEntityCoords(vehicle) -- Aktualisiere Koordinaten nach Positionsänderung + +FreezeEntityPosition(vehicle, true) +SetEntityInvincible(vehicle, true) + +local anchorData = { + coords = coords, + heading = heading, + time = GetGameTimer() +} + +anchoredBoats[vehicleNetId] = anchorData + +-- Speichere auf Server +saveAnchorToServer(vehicle, anchorData) + +QBCore.Functions.Notify('⚓ Anker geworfen! Das Boot ist jetzt verankert.', 'success') end end