Update stations.lua
This commit is contained in:
		
							parent
							
								
									6a9aa73201
								
							
						
					
					
						commit
						764079c6a7
					
				
					 1 changed files with 101 additions and 72 deletions
				
			
		|  | @ -830,50 +830,68 @@ function StartStationTaxiRide(stationId, vehicleId, vehicle, driver, destination | |||
| local drivingStyle = 786603 -- Normal/Vorsichtig | ||||
| TaskVehicleDriveToCoordLongrange(driver, vehicle, destination.x, destination.y, destination.z, 20.0, drivingStyle, 10.0) | ||||
|  | ||||
|   -- Fahrt überwachen | ||||
| CreateThread(function() | ||||
|     local lastPos = GetEntityCoords(vehicle) | ||||
|     local stuckCounter = 0 | ||||
|     local maxStuckCount = 20       -- Erhöht von 5 auf 20 für viel mehr Geduld | ||||
|     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 | ||||
|      | ||||
|     -- Fahrt überwachen | ||||
|     CreateThread(function() | ||||
|         local lastPos = GetEntityCoords(vehicle) | ||||
|         local stuckCounter = 0 | ||||
|         local maxStuckCount = 10 | ||||
|         local rideTimeout = GetGameTimer() + (10 * 60 * 1000) -- 5 Minuten Timeout | ||||
|     while DoesEntityExist(vehicle) and DoesEntityExist(driver) do | ||||
|         local vehicleCoords = GetEntityCoords(vehicle) | ||||
|         local distance = #(vector3(destination.x, destination.y, destination.z) - vehicleCoords) | ||||
|         local distanceMoved = #(lastPos - vehicleCoords) | ||||
|          | ||||
|         while DoesEntityExist(vehicle) and DoesEntityExist(driver) do | ||||
|             local vehicleCoords = GetEntityCoords(vehicle) | ||||
|             local distance = #(vector3(destination.x, destination.y, destination.z) - vehicleCoords) | ||||
|             local distanceMoved = #(lastPos - vehicleCoords) | ||||
|         -- Überprüfen ob wir angekommen sind | ||||
|         if distance < 10.0 then | ||||
|             -- Angekommen | ||||
|             TaskVehicleTempAction(driver, vehicle, 27, 3000) | ||||
|              | ||||
|             -- Überprüfen ob wir angekommen sind | ||||
|             if distance < 10.0 then | ||||
|                 -- Angekommen | ||||
|                 TaskVehicleTempAction(driver, vehicle, 27, 3000) | ||||
|                  | ||||
|                 print("^2[TAXI STATIONS DEBUG]^7 Arrived at destination") | ||||
|                 lib.notify({ | ||||
|                     title = 'Taxi Service', | ||||
|                     description = 'Du bist angekommen! Preis: $' .. price, | ||||
|                     type = 'success' | ||||
|                 }) | ||||
|                  | ||||
|                 -- Bezahlung | ||||
|                 TriggerServerEvent('taxi:payFare', price) | ||||
|                  | ||||
|                 -- Blip entfernen | ||||
|                 RemoveBlip(destinationBlip) | ||||
|                  | ||||
|                 -- Nach 10 Sekunden Taxi zurück zur Station | ||||
|                 SetTimeout(10000, function() | ||||
|                     ReturnTaxiToStation(stationId, vehicleId, vehicle, driver) | ||||
|                 end) | ||||
|                  | ||||
|                 break | ||||
|             print("^2[TAXI STATIONS DEBUG]^7 Arrived at destination") | ||||
|             lib.notify({ | ||||
|                 title = 'Taxi Service', | ||||
|                 description = 'Du bist angekommen! Preis: $' .. price, | ||||
|                 type = 'success' | ||||
|             }) | ||||
|              | ||||
|             -- Bezahlung | ||||
|             TriggerServerEvent('taxi:payFare', price) | ||||
|              | ||||
|             -- Blip entfernen | ||||
|             RemoveBlip(destinationBlip) | ||||
|              | ||||
|             -- Nach 10 Sekunden Taxi zurück zur Station | ||||
|             SetTimeout(10000, function() | ||||
|                 ReturnTaxiToStation(stationId, vehicleId, vehicle, driver) | ||||
|             end) | ||||
|              | ||||
|             break | ||||
|         end | ||||
|          | ||||
|         -- Überprüfen ob das Taxi stecken geblieben ist | ||||
|         -- 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 | ||||
|              | ||||
|             -- 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 | ||||
|              | ||||
|             -- Überprüfen ob das Taxi stecken geblieben ist | ||||
|             if distanceMoved < 1.0 then | ||||
|                 stuckCounter = stuckCounter + 1 | ||||
|                  | ||||
|                 if stuckCounter >= maxStuckCount then | ||||
|             -- Nur versuchen zu befreien, wenn wirklich lange steckengeblieben | ||||
|             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") | ||||
|                      | ||||
|                     -- Versuche, das Taxi zu befreien | ||||
|  | @ -895,47 +913,58 @@ TaskVehicleDriveToCoordLongrange(driver, vehicle, destination.x, destination.y, | |||
|                     local drivingStyle = 786603 -- Normal/Vorsichtig | ||||
|                     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 | ||||
|         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) | ||||
|             end | ||||
|         end | ||||
|          | ||||
|         -- Überprüfen ob die Fahrt zu lange dauert | ||||
|         if GetGameTimer() > rideTimeout then | ||||
|             print("^1[TAXI STATIONS DEBUG]^7 Taxi ride timed out!") | ||||
|             lib.notify({ | ||||
|                 title = 'Taxi Service', | ||||
|                 description = 'Die Fahrt dauert zu lange. Wir sind fast da!', | ||||
|                 type = 'warning' | ||||
|             }) | ||||
|              | ||||
|             -- Überprüfen ob die Fahrt zu lange dauert | ||||
|             if GetGameTimer() > rideTimeout then | ||||
|                 print("^1[TAXI STATIONS 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(vehicle, nearDestination.x, nearDestination.y, nearDestination.z, false, false, false, false) | ||||
|                  | ||||
|                 -- Neues Timeout setzen (1 Minute) | ||||
|                 rideTimeout = GetGameTimer() + (60 * 1000) | ||||
|             -- 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 | ||||
|              | ||||
|             lastPos = vehicleCoords | ||||
|             Wait(2000) | ||||
|             -- Teleportiere Taxi | ||||
|             SetEntityCoords(vehicle, nearDestination.x, nearDestination.y, nearDestination.z, false, false, false, false) | ||||
|              | ||||
|             -- Neues Timeout setzen (1 Minute) | ||||
|             rideTimeout = GetGameTimer() + (60 * 1000) | ||||
|         end | ||||
|     end) | ||||
| end | ||||
|          | ||||
|         lastPos = vehicleCoords | ||||
|         Wait(checkInterval) | ||||
|     end | ||||
| end) | ||||
|    | ||||
|  | ||||
|  | ||||
| function ExitStationTaxi(stationId, vehicleId, vehicle, driver) | ||||
|     print("^2[TAXI STATIONS DEBUG]^7 Player exiting station taxi") | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nordi98
						Nordi98