From 53583a708105e99a662bfb0174133efe44fd43fc Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Wed, 30 Jul 2025 07:02:08 +0200 Subject: [PATCH] Update main.lua --- resources/[tools]/nordi_taxi/client/main.lua | 75 ++++++++++++-------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/resources/[tools]/nordi_taxi/client/main.lua b/resources/[tools]/nordi_taxi/client/main.lua index 0c5601bde..a7c78815e 100644 --- a/resources/[tools]/nordi_taxi/client/main.lua +++ b/resources/[tools]/nordi_taxi/client/main.lua @@ -904,8 +904,8 @@ function MonitorTaxiRide(destination, price) local lastPos = GetEntityCoords(currentTaxi) local stuckCounter = 0 - local maxStuckCount = 5 - local rideTimeout = GetGameTimer() + (5 * 60 * 1000) -- 5 Minuten Timeout + local maxStuckCount = 10 + local rideTimeout = GetGameTimer() + (10 * 60 * 1000) -- 5 Minuten Timeout CreateThread(function() while DoesEntityExist(currentTaxi) and DoesEntityExist(currentDriver) do @@ -955,35 +955,48 @@ function MonitorTaxiRide(destination, price) stuckCounter = math.max(0, stuckCounter - 1) end - -- Überprüfen ob die Fahrt zu lange dauert - if GetGameTimer() > rideTimeout then - print("^1[TAXI DEBUG]^7 Taxi ride timed out!") - lib.notify({ - title = 'Taxi Service', - description = 'Die Fahrt dauert zu lange. Wir sind fast da!', - type = 'warning' - }) - - -- Teleportiere Taxi in die Nähe des Ziels - local offset = vector3( - math.random(-20, 20), - math.random(-20, 20), - 0 - ) - local nearDestination = vector3(destination.x, destination.y, destination.z) + offset - - -- Finde gültige Z-Koordinate - local success, groundZ = GetGroundZFor_3dCoord(nearDestination.x, nearDestination.y, nearDestination.z, true) - if success then - nearDestination = vector3(nearDestination.x, nearDestination.y, groundZ) - end - - -- Teleportiere Taxi - SetEntityCoords(currentTaxi, nearDestination.x, nearDestination.y, nearDestination.z, false, false, false, false) - - -- Neues Timeout setzen (1 Minute) - rideTimeout = GetGameTimer() + (60 * 1000) - end +-- Überprüfen ob die Fahrt zu lange dauert +if GetGameTimer() > rideTimeout then + print("^1[TAXI DEBUG]^7 Taxi ride timed out!") + + -- Berechne verbleibende Distanz + local taxiCoords = GetEntityCoords(currentTaxi) + local remainingDistance = #(vector3(destination.x, destination.y, destination.z) - taxiCoords) + + lib.notify({ + title = 'Taxi Service', + description = 'Die Fahrt dauert zu lange. Noch ' .. math.ceil(remainingDistance) .. 'm bis zum Ziel!', + type = 'warning' + }) + + -- Teleportiere Taxi näher ans Ziel (75% des Weges) + local direction = vector3( + destination.x - taxiCoords.x, + destination.y - taxiCoords.y, + destination.z - taxiCoords.z + ) + local normalizedDir = norm(direction) + local teleportDistance = remainingDistance * 0.75 + + local newPos = vector3( + taxiCoords.x + normalizedDir.x * teleportDistance, + taxiCoords.y + normalizedDir.y * teleportDistance, + taxiCoords.z + ) + + -- Finde gültige Z-Koordinate + local success, groundZ = GetGroundZFor_3dCoord(newPos.x, newPos.y, newPos.z, true) + if success then + newPos = vector3(newPos.x, newPos.y, groundZ) + end + + -- Teleportiere Taxi + SetEntityCoords(currentTaxi, newPos.x, newPos.y, newPos.z, false, false, false, false) + + -- Neues Timeout setzen (2 Minuten) + rideTimeout = GetGameTimer() + (2 * 60 * 1000) +end + lastPos = taxiCoords Wait(2000)