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 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
@ -958,33 +958,46 @@ function MonitorTaxiRide(destination, price)
-- Ü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. Wir sind fast da!',
description = 'Die Fahrt dauert zu lange. Noch ' .. math.ceil(remainingDistance) .. 'm bis zum Ziel!',
type = 'warning'
})
-- Teleportiere Taxi in die Nähe des Ziels
local offset = vector3(
math.random(-20, 20),
math.random(-20, 20),
0
-- 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
)
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)
local success, groundZ = GetGroundZFor_3dCoord(newPos.x, newPos.y, newPos.z, true)
if success then
nearDestination = vector3(nearDestination.x, nearDestination.y, groundZ)
newPos = vector3(newPos.x, newPos.y, groundZ)
end
-- Teleportiere Taxi
SetEntityCoords(currentTaxi, nearDestination.x, nearDestination.y, nearDestination.z, false, false, false, false)
SetEntityCoords(currentTaxi, newPos.x, newPos.y, newPos.z, false, false, false, false)
-- Neues Timeout setzen (1 Minute)
rideTimeout = GetGameTimer() + (60 * 1000)
-- Neues Timeout setzen (2 Minuten)
rideTimeout = GetGameTimer() + (2 * 60 * 1000)
end
lastPos = taxiCoords
Wait(2000)
end