forked from Simnation/Main
ed
This commit is contained in:
parent
61fb5c586e
commit
a47b4f6672
2 changed files with 124 additions and 3 deletions
|
@ -384,11 +384,19 @@ function MonitorTaxiArrival(taxi, driver, playerCoords)
|
||||||
print("^2[TAXI DEBUG]^7 Monitoring taxi arrival...")
|
print("^2[TAXI DEBUG]^7 Monitoring taxi arrival...")
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
|
local startTime = GetGameTimer()
|
||||||
|
local maxWaitTime = Config.MaxWaitTime * 1000
|
||||||
|
local lastDistance = 999999.0
|
||||||
|
local stuckCounter = 0
|
||||||
|
local routeRecalculated = false
|
||||||
|
|
||||||
while DoesEntityExist(taxi) and (not driver or DoesEntityExist(driver)) do
|
while DoesEntityExist(taxi) and (not driver or DoesEntityExist(driver)) do
|
||||||
local taxiCoords = GetEntityCoords(taxi)
|
local taxiCoords = GetEntityCoords(taxi)
|
||||||
local distance = #(playerCoords - taxiCoords)
|
local currentDistance = #(playerCoords - taxiCoords)
|
||||||
|
local elapsedTime = GetGameTimer() - startTime
|
||||||
|
|
||||||
if distance < 15.0 then
|
-- Taxi ist angekommen
|
||||||
|
if currentDistance < 15.0 then
|
||||||
print("^2[TAXI DEBUG]^7 Taxi arrived!")
|
print("^2[TAXI DEBUG]^7 Taxi arrived!")
|
||||||
|
|
||||||
-- Taxi stoppen
|
-- Taxi stoppen
|
||||||
|
@ -420,11 +428,124 @@ function MonitorTaxiArrival(taxi, driver, playerCoords)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Prüfen ob Taxi stecken geblieben ist
|
||||||
|
if math.abs(currentDistance - lastDistance) < 0.5 then
|
||||||
|
stuckCounter = stuckCounter + 1
|
||||||
|
else
|
||||||
|
stuckCounter = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Wenn Taxi zu lange stecken bleibt oder Zeit abgelaufen ist
|
||||||
|
if stuckCounter > 15 or (elapsedTime > maxWaitTime and currentDistance > 50.0) then
|
||||||
|
-- Versuche Route neu zu berechnen oder teleportiere näher
|
||||||
|
if not routeRecalculated then
|
||||||
|
print("^3[TAXI DEBUG]^7 Taxi seems stuck, recalculating route...")
|
||||||
|
|
||||||
|
-- Aktuelle Spielerposition holen (könnte sich bewegt haben)
|
||||||
|
local newPlayerCoords = GetEntityCoords(PlayerPedId())
|
||||||
|
|
||||||
|
-- Finde eine nahe Position auf der Straße
|
||||||
|
local streetCoords = FindNearestVehicleNode(newPlayerCoords.x, newPlayerCoords.y, newPlayerCoords.z, 1, 3.0, 0)
|
||||||
|
|
||||||
|
if streetCoords then
|
||||||
|
-- Neue Route zum Spieler setzen
|
||||||
|
ClearPedTasks(driver)
|
||||||
|
TaskVehicleDriveToCoord(driver, taxi, streetCoords.x, streetCoords.y, streetCoords.z, 25.0, 0, GetEntityModel(taxi), 786603, 1.0, true)
|
||||||
|
|
||||||
|
lib.notify({
|
||||||
|
title = 'Taxi Service',
|
||||||
|
description = 'Dein Taxi hat Schwierigkeiten dich zu erreichen. Es versucht einen anderen Weg.',
|
||||||
|
type = 'info'
|
||||||
|
})
|
||||||
|
|
||||||
|
routeRecalculated = true
|
||||||
|
stuckCounter = 0
|
||||||
|
else
|
||||||
|
-- Wenn keine Straße gefunden wurde, teleportiere näher
|
||||||
|
local teleportDistance = 100.0
|
||||||
|
local angle = math.random() * 2 * math.pi
|
||||||
|
local teleportX = newPlayerCoords.x + math.cos(angle) * teleportDistance
|
||||||
|
local teleportY = newPlayerCoords.y + math.sin(angle) * teleportDistance
|
||||||
|
|
||||||
|
-- Finde Z-Koordinate
|
||||||
|
local groundZ = 0.0
|
||||||
|
local foundGround, z = GetGroundZFor_3dCoord(teleportX, teleportY, newPlayerCoords.z + 50.0, groundZ, false)
|
||||||
|
|
||||||
|
if foundGround then
|
||||||
|
-- Teleportiere Taxi näher
|
||||||
|
SetEntityCoords(taxi, teleportX, teleportY, z + 1.0, false, false, false, false)
|
||||||
|
|
||||||
|
-- Neue Route setzen
|
||||||
|
ClearPedTasks(driver)
|
||||||
|
TaskVehicleDriveToCoord(driver, taxi, newPlayerCoords.x, newPlayerCoords.y, newPlayerCoords.z, 25.0, 0, GetEntityModel(taxi), 786603, 1.0, true)
|
||||||
|
|
||||||
|
lib.notify({
|
||||||
|
title = 'Taxi Service',
|
||||||
|
description = 'Dein Taxi wurde in deine Nähe teleportiert.',
|
||||||
|
type = 'info'
|
||||||
|
})
|
||||||
|
|
||||||
|
routeRecalculated = true
|
||||||
|
stuckCounter = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Wenn bereits versucht wurde, die Route neu zu berechnen, und es immer noch nicht funktioniert
|
||||||
|
if elapsedTime > maxWaitTime * 1.5 then
|
||||||
|
print("^1[TAXI DEBUG]^7 Taxi failed to arrive even after route recalculation")
|
||||||
|
|
||||||
|
-- Teleportiere direkt zum Spieler als letzten Ausweg
|
||||||
|
local newPlayerCoords = GetEntityCoords(PlayerPedId())
|
||||||
|
local heading = GetEntityHeading(taxi)
|
||||||
|
|
||||||
|
-- Finde eine Position in der Nähe des Spielers
|
||||||
|
local spawnDistance = 10.0
|
||||||
|
local angle = math.random() * 2 * math.pi
|
||||||
|
local spawnX = newPlayerCoords.x + math.cos(angle) * spawnDistance
|
||||||
|
local spawnY = newPlayerCoords.y + math.sin(angle) * spawnDistance
|
||||||
|
|
||||||
|
-- Teleportiere Taxi direkt zum Spieler
|
||||||
|
SetEntityCoords(taxi, spawnX, spawnY, newPlayerCoords.z, false, false, false, false)
|
||||||
|
SetEntityHeading(taxi, heading)
|
||||||
|
|
||||||
|
-- Stoppe das Taxi
|
||||||
|
if driver and DoesEntityExist(driver) then
|
||||||
|
TaskVehicleTempAction(driver, taxi, 27, 3000) -- Brake
|
||||||
|
Wait(2000)
|
||||||
|
SetVehicleDoorsLocked(taxi, 1) -- Unlock doors
|
||||||
|
end
|
||||||
|
|
||||||
|
lib.notify({
|
||||||
|
title = 'Taxi Service',
|
||||||
|
description = 'Dein Taxi ist angekommen! Steige ein.',
|
||||||
|
type = 'success'
|
||||||
|
})
|
||||||
|
|
||||||
|
-- qb-target für Einsteigen hinzufügen
|
||||||
|
exports['qb-target']:AddTargetEntity(taxi, {
|
||||||
|
options = {
|
||||||
|
{
|
||||||
|
type = "client",
|
||||||
|
event = "taxi:enterTaxi",
|
||||||
|
icon = "fas fa-car-side",
|
||||||
|
label = "Ins Taxi einsteigen"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
distance = 3.0
|
||||||
|
})
|
||||||
|
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
lastDistance = currentDistance
|
||||||
Wait(2000)
|
Wait(2000)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Event für Einsteigen ins Taxi
|
-- Event für Einsteigen ins Taxi
|
||||||
RegisterNetEvent('taxi:enterTaxi', function()
|
RegisterNetEvent('taxi:enterTaxi', function()
|
||||||
print("^2[TAXI DEBUG]^7 Player entering taxi")
|
print("^2[TAXI DEBUG]^7 Player entering taxi")
|
||||||
|
|
|
@ -138,7 +138,7 @@ Config.KnownDestinations = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "Maze Bank Tower",
|
name = "Maze Bank Tower",
|
||||||
coords = vector3(-75.0, -818.0, 326.0),
|
coords = vector3(-46.24, -787.47, 44.14),
|
||||||
price = 40
|
price = 40
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue