1
0
Fork 0
forked from Simnation/Main

Update stations.lua

This commit is contained in:
Nordi98 2025-07-30 08:31:19 +02:00
parent 6a9aa73201
commit 764079c6a7

View file

@ -830,13 +830,15 @@ function StartStationTaxiRide(stationId, vehicleId, vehicle, driver, destination
local drivingStyle = 786603 -- Normal/Vorsichtig local drivingStyle = 786603 -- Normal/Vorsichtig
TaskVehicleDriveToCoordLongrange(driver, vehicle, destination.x, destination.y, destination.z, 20.0, drivingStyle, 10.0) TaskVehicleDriveToCoordLongrange(driver, vehicle, destination.x, destination.y, destination.z, 20.0, drivingStyle, 10.0)
-- Fahrt überwachen -- Fahrt überwachen
CreateThread(function() CreateThread(function()
local lastPos = GetEntityCoords(vehicle) local lastPos = GetEntityCoords(vehicle)
local stuckCounter = 0 local stuckCounter = 0
local maxStuckCount = 10 local maxStuckCount = 20 -- Erhöht von 5 auf 20 für viel mehr Geduld
local rideTimeout = GetGameTimer() + (10 * 60 * 1000) -- 5 Minuten Timeout local stuckThreshold = 0.5 -- Reduziert von 1.0 auf 0.5 für genauere Erkennung
local checkInterval = 3000 -- Erhöht von 2000 auf 3000 ms für längere Prüfintervalle
local rideTimeout = GetGameTimer() + (8 * 60 * 1000) -- 8 Minuten Timeout (erhöht von 5)
local lastStuckWarning = 0 -- Zeitpunkt der letzten Steckenbleiben-Warnung
while DoesEntityExist(vehicle) and DoesEntityExist(driver) do while DoesEntityExist(vehicle) and DoesEntityExist(driver) do
local vehicleCoords = GetEntityCoords(vehicle) local vehicleCoords = GetEntityCoords(vehicle)
@ -870,10 +872,26 @@ TaskVehicleDriveToCoordLongrange(driver, vehicle, destination.x, destination.y,
end end
-- Überprüfen ob das Taxi stecken geblieben ist -- Überprüfen ob das Taxi stecken geblieben ist
if distanceMoved < 1.0 then -- Prüfe auch ob das Fahrzeug steht (Geschwindigkeit nahe 0)
local speed = GetEntitySpeed(vehicle)
local isAtRedLight = IsVehicleStoppedAtTrafficLights(vehicle)
-- Wenn das Fahrzeug an einer Ampel steht, nicht als steckengeblieben betrachten
if distanceMoved < stuckThreshold and speed < 0.5 and not isAtRedLight then
stuckCounter = stuckCounter + 1 stuckCounter = stuckCounter + 1
-- Nur alle 5 Zähler-Erhöhungen loggen, um Spam zu vermeiden
if stuckCounter % 5 == 0 then
print("^3[TAXI STATIONS DEBUG]^7 Taxi might be stuck: " .. stuckCounter .. "/" .. maxStuckCount)
end
-- Nur versuchen zu befreien, wenn wirklich lange steckengeblieben
if stuckCounter >= maxStuckCount then if stuckCounter >= maxStuckCount then
-- Mindestens 30 Sekunden zwischen Befreiungsversuchen warten
local currentTime = GetGameTimer()
if currentTime - lastStuckWarning > 30000 then
lastStuckWarning = currentTime
print("^1[TAXI STATIONS DEBUG]^7 Taxi stuck during ride, attempting recovery") print("^1[TAXI STATIONS DEBUG]^7 Taxi stuck during ride, attempting recovery")
-- Versuche, das Taxi zu befreien -- Versuche, das Taxi zu befreien
@ -895,11 +913,21 @@ TaskVehicleDriveToCoordLongrange(driver, vehicle, destination.x, destination.y,
local drivingStyle = 786603 -- Normal/Vorsichtig local drivingStyle = 786603 -- Normal/Vorsichtig
TaskVehicleDriveToCoordLongrange(driver, vehicle, destination.x, destination.y, destination.z, 20.0, drivingStyle, 10.0) TaskVehicleDriveToCoordLongrange(driver, vehicle, destination.x, destination.y, destination.z, 20.0, drivingStyle, 10.0)
stuckCounter = 0 -- Steckenbleiben-Zähler zurücksetzen, aber nicht ganz auf 0
-- So kann ein wirklich festgefahrenes Taxi nach einiger Zeit einen neuen Versuch starten
stuckCounter = maxStuckCount / 2
end
end end
else else
-- Wenn sich das Fahrzeug bewegt oder an einer Ampel steht, Zähler langsamer reduzieren
if isAtRedLight then
-- An Ampel: Zähler nicht erhöhen, aber auch nicht stark reduzieren
stuckCounter = math.max(0, stuckCounter - 0.2)
else
-- In Bewegung: Zähler reduzieren
stuckCounter = math.max(0, stuckCounter - 1) stuckCounter = math.max(0, stuckCounter - 1)
end end
end
-- Überprüfen ob die Fahrt zu lange dauert -- Überprüfen ob die Fahrt zu lange dauert
if GetGameTimer() > rideTimeout then if GetGameTimer() > rideTimeout then
@ -932,10 +960,11 @@ TaskVehicleDriveToCoordLongrange(driver, vehicle, destination.x, destination.y,
end end
lastPos = vehicleCoords lastPos = vehicleCoords
Wait(2000) Wait(checkInterval)
end end
end) end)
end
function ExitStationTaxi(stationId, vehicleId, vehicle, driver) function ExitStationTaxi(stationId, vehicleId, vehicle, driver)
print("^2[TAXI STATIONS DEBUG]^7 Player exiting station taxi") print("^2[TAXI STATIONS DEBUG]^7 Player exiting station taxi")