1
0
Fork 0
forked from Simnation/Main

Update main.lua

This commit is contained in:
Nordi98 2025-07-30 07:02:08 +02:00
parent 14b291106c
commit 53583a7081

View file

@ -904,8 +904,8 @@ function MonitorTaxiRide(destination, price)
local lastPos = GetEntityCoords(currentTaxi) local lastPos = GetEntityCoords(currentTaxi)
local stuckCounter = 0 local stuckCounter = 0
local maxStuckCount = 5 local maxStuckCount = 10
local rideTimeout = GetGameTimer() + (5 * 60 * 1000) -- 5 Minuten Timeout local rideTimeout = GetGameTimer() + (10 * 60 * 1000) -- 5 Minuten Timeout
CreateThread(function() CreateThread(function()
while DoesEntityExist(currentTaxi) and DoesEntityExist(currentDriver) do while DoesEntityExist(currentTaxi) and DoesEntityExist(currentDriver) do
@ -955,35 +955,48 @@ function MonitorTaxiRide(destination, price)
stuckCounter = math.max(0, stuckCounter - 1) stuckCounter = math.max(0, stuckCounter - 1)
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
print("^1[TAXI DEBUG]^7 Taxi ride timed out!") print("^1[TAXI DEBUG]^7 Taxi ride timed out!")
lib.notify({
title = 'Taxi Service', -- Berechne verbleibende Distanz
description = 'Die Fahrt dauert zu lange. Wir sind fast da!', local taxiCoords = GetEntityCoords(currentTaxi)
type = 'warning' local remainingDistance = #(vector3(destination.x, destination.y, destination.z) - taxiCoords)
})
lib.notify({
-- Teleportiere Taxi in die Nähe des Ziels title = 'Taxi Service',
local offset = vector3( description = 'Die Fahrt dauert zu lange. Noch ' .. math.ceil(remainingDistance) .. 'm bis zum Ziel!',
math.random(-20, 20), type = 'warning'
math.random(-20, 20), })
0
) -- Teleportiere Taxi näher ans Ziel (75% des Weges)
local nearDestination = vector3(destination.x, destination.y, destination.z) + offset local direction = vector3(
destination.x - taxiCoords.x,
-- Finde gültige Z-Koordinate destination.y - taxiCoords.y,
local success, groundZ = GetGroundZFor_3dCoord(nearDestination.x, nearDestination.y, nearDestination.z, true) destination.z - taxiCoords.z
if success then )
nearDestination = vector3(nearDestination.x, nearDestination.y, groundZ) local normalizedDir = norm(direction)
end local teleportDistance = remainingDistance * 0.75
-- Teleportiere Taxi local newPos = vector3(
SetEntityCoords(currentTaxi, nearDestination.x, nearDestination.y, nearDestination.z, false, false, false, false) taxiCoords.x + normalizedDir.x * teleportDistance,
taxiCoords.y + normalizedDir.y * teleportDistance,
-- Neues Timeout setzen (1 Minute) taxiCoords.z
rideTimeout = GetGameTimer() + (60 * 1000) )
end
-- 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 lastPos = taxiCoords
Wait(2000) Wait(2000)