ed
This commit is contained in:
parent
16b0058156
commit
3279494318
3 changed files with 193 additions and 168 deletions
|
@ -11,14 +11,14 @@ local taxiMeter = {
|
|||
pricePerKm = 0
|
||||
}
|
||||
|
||||
print("^2[TAXI DEBUG]^7 Main script loaded")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Main script loaded")
|
||||
|
||||
-- Taxi rufen Command
|
||||
RegisterCommand('taxi', function()
|
||||
print("^2[TAXI DEBUG]^7 Taxi command executed")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Taxi command executed")
|
||||
|
||||
if currentTaxi and DoesEntityExist(currentTaxi) then
|
||||
print("^1[TAXI DEBUG]^7 Taxi already exists")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Taxi already exists")
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Du hast bereits ein Taxi gerufen',
|
||||
|
@ -31,7 +31,7 @@ RegisterCommand('taxi', function()
|
|||
end)
|
||||
|
||||
function CallTaxi()
|
||||
print("^2[TAXI DEBUG]^7 CallTaxi function started")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 CallTaxi function started")
|
||||
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
|
@ -43,12 +43,12 @@ function CallTaxi()
|
|||
local playerPed = PlayerPedId()
|
||||
local playerCoords = GetEntityCoords(playerPed)
|
||||
|
||||
print("^2[TAXI DEBUG]^7 Player coords: " .. tostring(playerCoords))
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Player coords: " .. tostring(playerCoords))
|
||||
|
||||
-- Verbesserte Spawn-Position für Taxi finden
|
||||
local spawnCoords = GetImprovedTaxiSpawnPosition(playerCoords)
|
||||
if not spawnCoords then
|
||||
print("^1[TAXI DEBUG]^7 No spawn position found")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 No spawn position found")
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Kein geeigneter Spawn-Punkt gefunden',
|
||||
|
@ -57,12 +57,12 @@ function CallTaxi()
|
|||
return
|
||||
end
|
||||
|
||||
print("^2[TAXI DEBUG]^7 Spawn coords found: " .. tostring(spawnCoords.x) .. ", " .. tostring(spawnCoords.y) .. ", " .. tostring(spawnCoords.z))
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Spawn coords found: " .. tostring(spawnCoords.x) .. ", " .. tostring(spawnCoords.y) .. ", " .. tostring(spawnCoords.z))
|
||||
|
||||
-- Taxi spawnen
|
||||
local taxi = SpawnTaxi(spawnCoords)
|
||||
if not taxi then
|
||||
print("^1[TAXI DEBUG]^7 Failed to spawn taxi")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Failed to spawn taxi")
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Taxi konnte nicht gespawnt werden',
|
||||
|
@ -71,14 +71,14 @@ function CallTaxi()
|
|||
return
|
||||
end
|
||||
|
||||
print("^2[TAXI DEBUG]^7 Taxi spawned: " .. taxi)
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Taxi spawned: " .. taxi)
|
||||
currentTaxi = taxi
|
||||
|
||||
-- Fahrer spawnen
|
||||
local driver = SpawnTaxiDriver(taxi)
|
||||
if driver then
|
||||
currentDriver = driver
|
||||
print("^2[TAXI DEBUG]^7 Driver spawned: " .. driver)
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Driver spawned: " .. driver)
|
||||
|
||||
-- Verbesserte Navigation zum Spieler
|
||||
NavigateToPlayer(driver, taxi, playerCoords)
|
||||
|
@ -95,7 +95,7 @@ function CallTaxi()
|
|||
type = 'success'
|
||||
})
|
||||
else
|
||||
print("^1[TAXI DEBUG]^7 Failed to spawn driver")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Failed to spawn driver")
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Taxi ohne Fahrer gespawnt - Du kannst es selbst fahren',
|
||||
|
@ -106,7 +106,7 @@ function CallTaxi()
|
|||
end
|
||||
|
||||
function GetImprovedTaxiSpawnPosition(playerCoords)
|
||||
print("^2[TAXI DEBUG]^7 Finding improved spawn position...")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Finding improved spawn position...")
|
||||
|
||||
-- Minimale und maximale Entfernung zum Spieler
|
||||
local minAcceptableDistance = 50.0 -- Mindestens 50 Meter entfernt
|
||||
|
@ -127,7 +127,7 @@ function GetImprovedTaxiSpawnPosition(playerCoords)
|
|||
local nodeDistance = #(playerCoords - nodePos)
|
||||
if nodeDistance >= minAcceptableDistance and nodeDistance <= maxAcceptableDistance then
|
||||
roadPosition = nodePos
|
||||
print("^2[TAXI DEBUG]^7 Found road node for spawn at distance: " .. nodeDistance)
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Found road node for spawn at distance: " .. nodeDistance)
|
||||
return {x = roadPosition.x, y = roadPosition.y, z = roadPosition.z, w = 0.0}
|
||||
else
|
||||
-- Speichern für später, falls wir nichts Besseres finden
|
||||
|
@ -150,7 +150,7 @@ function GetImprovedTaxiSpawnPosition(playerCoords)
|
|||
if foundNode then
|
||||
local nodeDistance = #(playerCoords - nodePos)
|
||||
if nodeDistance >= minAcceptableDistance and nodeDistance <= maxAcceptableDistance then
|
||||
print("^2[TAXI DEBUG]^7 Found directional node for spawn at distance: " .. nodeDistance .. " in direction " .. angle)
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Found directional node for spawn at distance: " .. nodeDistance .. " in direction " .. angle)
|
||||
return {x = nodePos.x, y = nodePos.y, z = nodePos.z, w = 0.0}
|
||||
else
|
||||
-- Speichern für später, falls wir nichts Besseres finden
|
||||
|
@ -169,7 +169,7 @@ function GetImprovedTaxiSpawnPosition(playerCoords)
|
|||
local nodeDistance = #(playerCoords - nodePos)
|
||||
if nodeDistance >= minAcceptableDistance and nodeDistance <= maxAcceptableDistance then
|
||||
roadPosition = nodePos
|
||||
print("^2[TAXI DEBUG]^7 Found major road node for spawn at distance: " .. nodeDistance)
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Found major road node for spawn at distance: " .. nodeDistance)
|
||||
return {x = roadPosition.x, y = roadPosition.y, z = roadPosition.z, w = 0.0}
|
||||
else
|
||||
-- Speichern für später, falls wir nichts Besseres finden
|
||||
|
@ -228,7 +228,7 @@ function GetImprovedTaxiSpawnPosition(playerCoords)
|
|||
|
||||
-- Wenn Position frei ist, verwenden
|
||||
if clearArea then
|
||||
print("^2[TAXI DEBUG]^7 Using spawn position from config: " .. tostring(spawnCoords.x) .. ", " .. tostring(spawnCoords.y) .. ", " .. tostring(spawnCoords.z) .. " (Distance: " .. spawn.distance .. "m)")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Using spawn position from config: " .. tostring(spawnCoords.x) .. ", " .. tostring(spawnCoords.y) .. ", " .. tostring(spawnCoords.z) .. " (Distance: " .. spawn.distance .. "m)")
|
||||
return spawnCoords
|
||||
end
|
||||
|
||||
|
@ -239,12 +239,12 @@ function GetImprovedTaxiSpawnPosition(playerCoords)
|
|||
-- Wenn wir hier sind, haben wir keine ideale Position gefunden
|
||||
-- Wenn wir eine "beste" Position haben, die den Mindestabstand einhält, verwenden wir diese
|
||||
if bestPosition and bestDistance >= minAcceptableDistance then
|
||||
print("^3[TAXI DEBUG]^7 Using best available position at " .. bestDistance .. "m")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Using best available position at " .. bestDistance .. "m")
|
||||
return bestPosition
|
||||
end
|
||||
|
||||
-- Wenn alles fehlschlägt: Generiere eine zufällige Position in der Nähe des Spielers
|
||||
print("^3[TAXI DEBUG]^7 Generating random position between " .. minAcceptableDistance .. "m and " .. maxAcceptableDistance .. "m of player")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Generating random position between " .. minAcceptableDistance .. "m and " .. maxAcceptableDistance .. "m of player")
|
||||
|
||||
-- Versuche bis zu 15 Mal, eine gültige Position zu finden
|
||||
for attempt = 1, 15 do
|
||||
|
@ -262,7 +262,7 @@ function GetImprovedTaxiSpawnPosition(playerCoords)
|
|||
local isOnRoad = IsPointOnRoad(x, y, groundZ)
|
||||
|
||||
if isOnRoad then
|
||||
print("^2[TAXI DEBUG]^7 Found random position on road at distance: " .. distance)
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Found random position on road at distance: " .. distance)
|
||||
return {x = x, y = y, z = groundZ, w = 0.0}
|
||||
end
|
||||
end
|
||||
|
@ -281,13 +281,13 @@ function GetImprovedTaxiSpawnPosition(playerCoords)
|
|||
z = groundZ
|
||||
end
|
||||
|
||||
print("^3[TAXI DEBUG]^7 Using emergency random spawn position at distance: " .. distance)
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Using emergency random spawn position at distance: " .. distance)
|
||||
return {x = x, y = y, z = z, w = 0.0}
|
||||
end
|
||||
|
||||
|
||||
function SpawnTaxi(coords)
|
||||
print("^2[TAXI DEBUG]^7 Spawning taxi at: " .. tostring(coords.x) .. ", " .. tostring(coords.y) .. ", " .. tostring(coords.z))
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Spawning taxi at: " .. tostring(coords.x) .. ", " .. tostring(coords.y) .. ", " .. tostring(coords.z))
|
||||
|
||||
-- Sicherstellen dass wir ein gültiges Taxi-Model haben
|
||||
local taxiModel = nil
|
||||
|
@ -299,7 +299,7 @@ function SpawnTaxi(coords)
|
|||
taxiModel = GetHashKey("taxi") -- Fallback
|
||||
end
|
||||
|
||||
print("^2[TAXI DEBUG]^7 Taxi model hash: " .. taxiModel)
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Taxi model hash: " .. taxiModel)
|
||||
|
||||
-- Model laden mit Timeout
|
||||
RequestModel(taxiModel)
|
||||
|
@ -309,13 +309,13 @@ function SpawnTaxi(coords)
|
|||
while not modelLoaded and GetGameTimer() < timeout do
|
||||
modelLoaded = HasModelLoaded(taxiModel)
|
||||
if not modelLoaded then
|
||||
print("^3[TAXI DEBUG]^7 Waiting for taxi model to load...")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Waiting for taxi model to load...")
|
||||
Wait(100)
|
||||
end
|
||||
end
|
||||
|
||||
if not modelLoaded then
|
||||
print("^1[TAXI DEBUG]^7 Failed to load taxi model! Trying default model.")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Failed to load taxi model! Trying default model.")
|
||||
SetModelAsNoLongerNeeded(taxiModel)
|
||||
|
||||
-- Versuche Standard-Taxi als Fallback
|
||||
|
@ -328,7 +328,7 @@ function SpawnTaxi(coords)
|
|||
end
|
||||
|
||||
if not HasModelLoaded(taxiModel) then
|
||||
print("^1[TAXI DEBUG]^7 Failed to load default taxi model!")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Failed to load default taxi model!")
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
@ -337,11 +337,11 @@ function SpawnTaxi(coords)
|
|||
local taxi = CreateVehicle(taxiModel, coords.x, coords.y, coords.z, coords.w or 0.0, true, false)
|
||||
|
||||
if not DoesEntityExist(taxi) then
|
||||
print("^1[TAXI DEBUG]^7 Failed to create taxi vehicle!")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Failed to create taxi vehicle!")
|
||||
return nil
|
||||
end
|
||||
|
||||
print("^2[TAXI DEBUG]^7 Taxi created successfully: " .. taxi)
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Taxi created successfully: " .. taxi)
|
||||
|
||||
-- Fahrzeug konfigurieren
|
||||
SetEntityAsMissionEntity(taxi, true, true)
|
||||
|
@ -361,7 +361,7 @@ function SpawnTaxi(coords)
|
|||
local liveryCount = GetVehicleLiveryCount(taxi)
|
||||
if liveryCount > 0 then
|
||||
SetVehicleLivery(taxi, 0) -- Erste Livery verwenden
|
||||
print("^2[TAXI DEBUG]^7 Taxi livery set")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Taxi livery set")
|
||||
end
|
||||
|
||||
-- Fahrzeug-Extras aktivieren falls vorhanden
|
||||
|
@ -382,7 +382,7 @@ end
|
|||
function InitializeTaxiDriverAI(driver, vehicle)
|
||||
if not driver or not DoesEntityExist(driver) then return end
|
||||
|
||||
print("^2[TAXI DEBUG]^7 Initializing advanced taxi driver AI")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Initializing advanced taxi driver AI")
|
||||
|
||||
-- Fahrer-Persönlichkeit und Fähigkeiten zufällig festlegen
|
||||
local driverData = {
|
||||
|
@ -465,14 +465,14 @@ function InitializeTaxiDriverAI(driver, vehicle)
|
|||
-- Gerade an Ampel angekommen
|
||||
driverData.state.isWaitingAtTrafficLight = true
|
||||
driverData.state.trafficLightWaitStart = currentTime
|
||||
print("^3[TAXI DEBUG]^7 Taxi waiting at traffic light")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Taxi waiting at traffic light")
|
||||
elseif isAtTrafficLight and driverData.state.isWaitingAtTrafficLight then
|
||||
-- Immer noch an Ampel
|
||||
local waitTime = currentTime - driverData.state.trafficLightWaitStart
|
||||
|
||||
-- Wenn zu lange an Ampel, versuche weiterzufahren (Ampel könnte hängen)
|
||||
if waitTime > driverData.settings.trafficLightMaxWait then
|
||||
print("^3[TAXI DEBUG]^7 Taxi waited too long at traffic light, trying to continue")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Taxi waited too long at traffic light, trying to continue")
|
||||
-- Kurz vorwärts fahren um Ampel zu überwinden
|
||||
TaskVehicleTempAction(driver, vehicle, 1, 2000) -- Forward
|
||||
Wait(2000)
|
||||
|
@ -483,7 +483,7 @@ function InitializeTaxiDriverAI(driver, vehicle)
|
|||
elseif not isAtTrafficLight and driverData.state.isWaitingAtTrafficLight then
|
||||
-- Ampel verlassen
|
||||
driverData.state.isWaitingAtTrafficLight = false
|
||||
print("^2[TAXI DEBUG]^7 Taxi continued after traffic light")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Taxi continued after traffic light")
|
||||
end
|
||||
|
||||
-- Steckenbleiben-Erkennung (nicht an Ampel und kaum Bewegung)
|
||||
|
@ -492,14 +492,14 @@ function InitializeTaxiDriverAI(driver, vehicle)
|
|||
|
||||
-- Nur alle 5 Zähler-Erhöhungen loggen
|
||||
if driverData.state.stuckCounter % 5 == 0 then
|
||||
print("^3[TAXI DEBUG]^7 Taxi might be stuck: " .. driverData.state.stuckCounter .. "/" .. driverData.settings.maxStuckCounter)
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Taxi might be stuck: " .. driverData.state.stuckCounter .. "/" .. driverData.settings.maxStuckCounter)
|
||||
end
|
||||
|
||||
-- Wenn lange genug steckengeblieben und genug Zeit seit letztem Versuch
|
||||
if driverData.state.stuckCounter >= driverData.settings.maxStuckCounter and
|
||||
(currentTime - driverData.state.lastStuckRecovery) > driverData.settings.minRecoveryInterval then
|
||||
|
||||
print("^1[TAXI DEBUG]^7 Taxi is stuck, attempting intelligent recovery")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Taxi is stuck, attempting intelligent recovery")
|
||||
driverData.state.lastStuckRecovery = currentTime
|
||||
driverData.state.currentBehavior = "recovery"
|
||||
|
||||
|
@ -522,7 +522,7 @@ function InitializeTaxiDriverAI(driver, vehicle)
|
|||
if avgSpeed < 2.0 and driverData.state.stuckCounter > driverData.settings.maxStuckCounter * 0.5 and
|
||||
(currentTime - driverData.state.lastRouteRecalculation) > driverData.settings.minRouteRecalcInterval then
|
||||
|
||||
print("^3[TAXI DEBUG]^7 Taxi moving too slow, recalculating route")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Taxi moving too slow, recalculating route")
|
||||
driverData.state.lastRouteRecalculation = currentTime
|
||||
|
||||
-- Route neu berechnen
|
||||
|
@ -570,17 +570,17 @@ function TaxiDriverIntelligentRecovery(driver, vehicle)
|
|||
|
||||
if backwardClear then
|
||||
-- Rückwärts fahren wenn hinten frei
|
||||
print("^3[TAXI DEBUG]^7 Recovery: Backing up")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Recovery: Backing up")
|
||||
TaskVehicleTempAction(driver, vehicle, 8, 2000) -- Reverse
|
||||
Wait(2000)
|
||||
|
||||
if forwardClear then
|
||||
-- Wenn vorne auch frei, einfach weiterfahren
|
||||
print("^3[TAXI DEBUG]^7 Recovery: Path clear, continuing")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Recovery: Path clear, continuing")
|
||||
TaxiDriverContinueRoute(driver, vehicle)
|
||||
else
|
||||
-- Sonst versuchen zu wenden
|
||||
print("^3[TAXI DEBUG]^7 Recovery: Turning around")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Recovery: Turning around")
|
||||
TaskVehicleTempAction(driver, vehicle, 7, 2000) -- Turn left
|
||||
Wait(1000)
|
||||
TaskVehicleTempAction(driver, vehicle, 8, 1000) -- Reverse
|
||||
|
@ -591,13 +591,13 @@ function TaxiDriverIntelligentRecovery(driver, vehicle)
|
|||
end
|
||||
elseif forwardClear then
|
||||
-- Wenn nur vorne frei, vorwärts fahren
|
||||
print("^3[TAXI DEBUG]^7 Recovery: Moving forward")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Recovery: Moving forward")
|
||||
TaskVehicleTempAction(driver, vehicle, 1, 2000) -- Forward
|
||||
Wait(2000)
|
||||
TaxiDriverContinueRoute(driver, vehicle)
|
||||
else
|
||||
-- Wenn komplett eingeklemmt, versuche zu rütteln
|
||||
print("^3[TAXI DEBUG]^7 Recovery: Trying to wiggle free")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Recovery: Trying to wiggle free")
|
||||
TaskVehicleTempAction(driver, vehicle, 7, 1000) -- Turn left
|
||||
Wait(1000)
|
||||
TaskVehicleTempAction(driver, vehicle, 8, 800) -- Reverse
|
||||
|
@ -619,7 +619,7 @@ function TaxiDriverRecalculateRoute(driver, vehicle)
|
|||
|
||||
if destination then
|
||||
-- Versuche einen alternativen Weg zu finden
|
||||
print("^3[TAXI DEBUG]^7 Recalculating route to destination")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Recalculating route to destination")
|
||||
|
||||
-- Kurz anhalten
|
||||
TaskVehicleTempAction(driver, vehicle, 27, 1000) -- Stop
|
||||
|
@ -714,7 +714,7 @@ function norm(vector)
|
|||
end
|
||||
|
||||
function SpawnTaxiDriver(vehicle)
|
||||
print("^2[TAXI DEBUG]^7 Spawning taxi driver...")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Spawning taxi driver...")
|
||||
|
||||
-- Bessere Fahrer-Models mit Fallbacks
|
||||
local driverModels = {
|
||||
|
@ -733,7 +733,7 @@ function SpawnTaxiDriver(vehicle)
|
|||
|
||||
-- Versuche verschiedene Models
|
||||
for i, modelName in ipairs(driverModels) do
|
||||
print("^2[TAXI DEBUG]^7 Trying driver model " .. i .. ": " .. modelName)
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Trying driver model " .. i .. ": " .. modelName)
|
||||
driverHash = GetHashKey(modelName)
|
||||
|
||||
-- Model laden
|
||||
|
@ -744,38 +744,38 @@ function SpawnTaxiDriver(vehicle)
|
|||
while not HasModelLoaded(driverHash) and GetGameTimer() < timeout do
|
||||
attempts = attempts + 1
|
||||
if attempts % 10 == 0 then -- Alle 1 Sekunde loggen
|
||||
print("^3[TAXI DEBUG]^7 Still waiting for model " .. modelName .. " (attempt " .. attempts .. ")")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 Still waiting for model " .. modelName .. " (attempt " .. attempts .. ")")
|
||||
end
|
||||
Wait(100)
|
||||
end
|
||||
|
||||
if HasModelLoaded(driverHash) then
|
||||
print("^2[TAXI DEBUG]^7 Model " .. modelName .. " loaded successfully after " .. attempts .. " attempts")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Model " .. modelName .. " loaded successfully after " .. attempts .. " attempts")
|
||||
|
||||
-- Fahrer erstellen
|
||||
driver = CreatePedInsideVehicle(vehicle, 26, driverHash, -1, true, false)
|
||||
|
||||
if DoesEntityExist(driver) then
|
||||
print("^2[TAXI DEBUG]^7 Driver created successfully with model: " .. modelName .. " (ID: " .. driver .. ")")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Driver created successfully with model: " .. modelName .. " (ID: " .. driver .. ")")
|
||||
break
|
||||
else
|
||||
print("^1[TAXI DEBUG]^7 Failed to create driver with loaded model: " .. modelName)
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Failed to create driver with loaded model: " .. modelName)
|
||||
SetModelAsNoLongerNeeded(driverHash)
|
||||
end
|
||||
else
|
||||
print("^1[TAXI DEBUG]^7 Failed to load driver model: " .. modelName)
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Failed to load driver model: " .. modelName)
|
||||
SetModelAsNoLongerNeeded(driverHash)
|
||||
end
|
||||
end
|
||||
|
||||
-- Wenn immer noch kein Fahrer erstellt wurde
|
||||
if not driver or not DoesEntityExist(driver) then
|
||||
print("^1[TAXI DEBUG]^7 Could not create any driver! Continuing without driver...")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Could not create any driver! Continuing without driver...")
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Fahrer konfigurieren
|
||||
print("^2[TAXI DEBUG]^7 Configuring driver...")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Configuring driver...")
|
||||
|
||||
SetEntityAsMissionEntity(driver, true, true)
|
||||
SetBlockingOfNonTemporaryEvents(driver, true)
|
||||
|
@ -799,7 +799,7 @@ function SpawnTaxiDriver(vehicle)
|
|||
|
||||
-- Fahrer-Outfit (nur wenn es ein anpassbarer Ped ist)
|
||||
if driverHash == GetHashKey("mp_m_freemode_01") then
|
||||
print("^2[TAXI DEBUG]^7 Setting driver outfit...")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Setting driver outfit...")
|
||||
|
||||
-- Basis-Outfit für Taxi-Fahrer
|
||||
SetPedComponentVariation(driver, 0, 0, 0, 0) -- Face
|
||||
|
@ -824,7 +824,7 @@ function SpawnTaxiDriver(vehicle)
|
|||
SetModelAsNoLongerNeeded(driverHash)
|
||||
end
|
||||
|
||||
print("^2[TAXI DEBUG]^7 Driver spawn completed successfully")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Driver spawn completed successfully")
|
||||
return driver
|
||||
end
|
||||
|
||||
|
@ -869,7 +869,7 @@ function CreateTaxiBlips(taxi)
|
|||
end
|
||||
|
||||
function NavigateToPlayer(driver, taxi, playerCoords)
|
||||
print("^2[TAXI DEBUG]^7 Navigating taxi to player...")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Navigating taxi to player...")
|
||||
|
||||
-- Ziel im Fahrzeug-State speichern für die KI-Logik
|
||||
Entity(taxi).state.currentDestination = playerCoords
|
||||
|
@ -878,18 +878,18 @@ function NavigateToPlayer(driver, taxi, playerCoords)
|
|||
local success, nodePos = GetClosestVehicleNodeWithHeading(playerCoords.x, playerCoords.y, playerCoords.z, 1, 3.0, 0)
|
||||
|
||||
if success then
|
||||
print("^2[TAXI DEBUG]^7 Found good vehicle node near player")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Found good vehicle node near player")
|
||||
-- Zum Wegpunkt fahren
|
||||
TaskVehicleDriveToCoordLongrange(driver, taxi, nodePos.x, nodePos.y, nodePos.z, 20.0, 786603, 10.0)
|
||||
else
|
||||
print("^3[TAXI DEBUG]^7 No good vehicle node found, driving directly to player")
|
||||
DebugPrint("^3[TAXI DEBUG]^7 No good vehicle node found, driving directly to player")
|
||||
-- Direkt zum Spieler fahren
|
||||
TaskVehicleDriveToCoordLongrange(driver, taxi, playerCoords.x, playerCoords.y, playerCoords.z, 20.0, 786603, 10.0)
|
||||
end
|
||||
end
|
||||
|
||||
function MonitorTaxiArrival(taxi, driver, playerCoords)
|
||||
print("^2[TAXI DEBUG]^7 Monitoring taxi arrival...")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Monitoring taxi arrival...")
|
||||
|
||||
local arrivalTimeout = GetGameTimer() + (120 * 1000) -- 2 minute timeout
|
||||
|
||||
|
@ -901,7 +901,7 @@ function MonitorTaxiArrival(taxi, driver, playerCoords)
|
|||
|
||||
-- Check if taxi is close to player
|
||||
if distance < 15.0 then
|
||||
print("^2[TAXI DEBUG]^7 Taxi arrived!")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Taxi arrived!")
|
||||
|
||||
-- Taxi stoppen
|
||||
if driver and DoesEntityExist(driver) then
|
||||
|
@ -934,7 +934,7 @@ function MonitorTaxiArrival(taxi, driver, playerCoords)
|
|||
|
||||
-- Check for timeout
|
||||
if GetGameTimer() > arrivalTimeout then
|
||||
print("^1[TAXI DEBUG]^7 Taxi arrival timed out!")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Taxi arrival timed out!")
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Dein Taxi steckt fest. Ein neues wird gerufen!',
|
||||
|
@ -955,10 +955,10 @@ end
|
|||
|
||||
-- Event für Einsteigen ins Taxi
|
||||
RegisterNetEvent('taxi:enterTaxi', function()
|
||||
print("^2[TAXI DEBUG]^7 Player entering taxi")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Player entering taxi")
|
||||
|
||||
if not currentTaxi or not DoesEntityExist(currentTaxi) then
|
||||
print("^1[TAXI DEBUG]^7 No taxi exists")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 No taxi exists")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -983,7 +983,7 @@ RegisterNetEvent('taxi:enterTaxi', function()
|
|||
while GetGameTimer() < timeout and not entered do
|
||||
if IsPedInVehicle(playerPed, currentTaxi, false) then
|
||||
entered = true
|
||||
print("^2[TAXI DEBUG]^7 Player entered taxi successfully")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Player entered taxi successfully")
|
||||
|
||||
-- qb-target entfernen
|
||||
exports['qb-target']:RemoveTargetEntity(currentTaxi)
|
||||
|
@ -1002,7 +1002,7 @@ RegisterNetEvent('taxi:enterTaxi', function()
|
|||
end
|
||||
|
||||
if not entered then
|
||||
print("^1[TAXI DEBUG]^7 Player failed to enter taxi")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Player failed to enter taxi")
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Einsteigen fehlgeschlagen',
|
||||
|
@ -1013,7 +1013,7 @@ RegisterNetEvent('taxi:enterTaxi', function()
|
|||
end)
|
||||
|
||||
function OpenDestinationMenu()
|
||||
print("^2[TAXI DEBUG]^7 Opening destination menu")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Opening destination menu")
|
||||
|
||||
local options = {}
|
||||
|
||||
|
@ -1087,10 +1087,10 @@ function OpenDestinationMenu()
|
|||
end
|
||||
|
||||
function StartTaxiRide(destination, price)
|
||||
print("^2[TAXI DEBUG]^7 Starting taxi ride to: " .. tostring(destination.x) .. ", " .. tostring(destination.y) .. ", " .. tostring(destination.z))
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Starting taxi ride to: " .. tostring(destination.x) .. ", " .. tostring(destination.y) .. ", " .. tostring(destination.z))
|
||||
|
||||
if not currentTaxi or not DoesEntityExist(currentTaxi) then
|
||||
print("^1[TAXI DEBUG]^7 No taxi exists for ride")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 No taxi exists for ride")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -1164,7 +1164,7 @@ function StartTaxiRide(destination, price)
|
|||
end
|
||||
|
||||
function MonitorTaxiRide(destination, price)
|
||||
print("^2[TAXI DEBUG]^7 Monitoring taxi ride...")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Monitoring taxi ride...")
|
||||
|
||||
local rideTimeout = GetGameTimer() + (10 * 60 * 1000) -- 10 Minuten Timeout
|
||||
|
||||
|
@ -1178,7 +1178,7 @@ function MonitorTaxiRide(destination, price)
|
|||
-- Angekommen
|
||||
TaskVehicleTempAction(currentDriver, currentTaxi, 27, 3000)
|
||||
|
||||
print("^2[TAXI DEBUG]^7 Arrived at destination")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Arrived at destination")
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Du bist angekommen! Preis: $' .. price,
|
||||
|
@ -1222,7 +1222,7 @@ 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!")
|
||||
DebugPrint("^1[TAXI DEBUG]^7 Taxi ride timed out!")
|
||||
|
||||
-- Berechne verbleibende Distanz
|
||||
local taxiCoords = GetEntityCoords(currentTaxi)
|
||||
|
@ -1268,7 +1268,7 @@ function MonitorTaxiRide(destination, price)
|
|||
end
|
||||
|
||||
function SelfDriveTaxi()
|
||||
print("^2[TAXI DEBUG]^7 Player driving taxi themselves")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Player driving taxi themselves")
|
||||
|
||||
if not currentTaxi or not DoesEntityExist(currentTaxi) then
|
||||
return
|
||||
|
@ -1293,7 +1293,7 @@ function SelfDriveTaxi()
|
|||
end
|
||||
|
||||
function ExitTaxi()
|
||||
print("^2[TAXI DEBUG]^7 Player exiting taxi")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Player exiting taxi")
|
||||
|
||||
if not currentTaxi or not DoesEntityExist(currentTaxi) then
|
||||
return
|
||||
|
@ -1315,7 +1315,7 @@ function ExitTaxi()
|
|||
end
|
||||
|
||||
function DespawnTaxi()
|
||||
print("^2[TAXI DEBUG]^7 Despawning taxi")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Despawning taxi")
|
||||
|
||||
if not currentTaxi or not DoesEntityExist(currentTaxi) then
|
||||
return
|
||||
|
@ -1323,7 +1323,7 @@ function DespawnTaxi()
|
|||
|
||||
-- Taxi wegfahren lassen, wenn ein Fahrer existiert
|
||||
if currentDriver and DoesEntityExist(currentDriver) then
|
||||
print("^2[TAXI DEBUG]^7 Making taxi drive away before despawn")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Making taxi drive away before despawn")
|
||||
|
||||
-- Zufällige Position in der Nähe finden
|
||||
local taxiCoords = GetEntityCoords(currentTaxi)
|
||||
|
@ -1357,7 +1357,7 @@ function DespawnTaxi()
|
|||
if currentDriver and DoesEntityExist(currentDriver) then
|
||||
DeleteEntity(currentDriver)
|
||||
currentDriver = nil
|
||||
print("^2[TAXI DEBUG]^7 Driver deleted")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Driver deleted")
|
||||
end
|
||||
|
||||
-- Taxi löschen
|
||||
|
@ -1365,9 +1365,9 @@ function DespawnTaxi()
|
|||
exports['qb-target']:RemoveTargetEntity(currentTaxi)
|
||||
DeleteEntity(currentTaxi)
|
||||
currentTaxi = nil
|
||||
print("^2[TAXI DEBUG]^7 Taxi deleted")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Taxi deleted")
|
||||
end
|
||||
print("^2[TAXI DEBUG]^7 Taxi despawn completed")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Taxi despawn completed")
|
||||
end)
|
||||
else
|
||||
-- Sofort löschen wenn kein Fahrer da ist
|
||||
|
@ -1391,10 +1391,10 @@ function DespawnTaxi()
|
|||
exports['qb-target']:RemoveTargetEntity(currentTaxi)
|
||||
DeleteEntity(currentTaxi)
|
||||
currentTaxi = nil
|
||||
print("^2[TAXI DEBUG]^7 Taxi deleted")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Taxi deleted")
|
||||
end
|
||||
|
||||
print("^2[TAXI DEBUG]^7 Taxi despawn completed (no driver)")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Taxi despawn completed (no driver)")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1464,7 +1464,7 @@ end)
|
|||
|
||||
-- Funktion zum Beenden der Fahrt
|
||||
function EndTaxiRide()
|
||||
print("^2[TAXI DEBUG]^7 Ending taxi ride")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Ending taxi ride")
|
||||
|
||||
if not currentTaxi or not DoesEntityExist(currentTaxi) then
|
||||
return
|
||||
|
@ -1562,7 +1562,7 @@ end)
|
|||
-- Cleanup beim Resource Stop
|
||||
AddEventHandler('onResourceStop', function(resourceName)
|
||||
if GetCurrentResourceName() == resourceName then
|
||||
print("^2[TAXI DEBUG]^7 Cleaning up main script...")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Cleaning up main script...")
|
||||
|
||||
-- UI ausblenden
|
||||
lib.hideTextUI()
|
||||
|
@ -1570,9 +1570,20 @@ AddEventHandler('onResourceStop', function(resourceName)
|
|||
-- Taxi despawnen
|
||||
DespawnTaxi()
|
||||
|
||||
print("^2[TAXI DEBUG]^7 Main cleanup completed")
|
||||
DebugPrint("^2[TAXI DEBUG]^7 Main cleanup completed")
|
||||
end
|
||||
end)
|
||||
|
||||
function DebugPrint(type, message)
|
||||
if Config.Debug then
|
||||
if type == "error" then
|
||||
print("^1[TAXI DEBUG]^7 " .. message)
|
||||
elseif type == "warning" then
|
||||
print("^3[TAXI DEBUG]^7 " .. message)
|
||||
else -- success/info
|
||||
print("^2[TAXI DEBUG]^7 " .. message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue