forked from Simnation/Main
Update main.lua
This commit is contained in:
parent
14b291106c
commit
53583a7081
1 changed files with 44 additions and 31 deletions
|
@ -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
|
||||
-- Ü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 (2 Minuten)
|
||||
rideTimeout = GetGameTimer() + (2 * 60 * 1000)
|
||||
end
|
||||
|
||||
-- Neues Timeout setzen (1 Minute)
|
||||
rideTimeout = GetGameTimer() + (60 * 1000)
|
||||
end
|
||||
|
||||
lastPos = taxiCoords
|
||||
Wait(2000)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue