This commit is contained in:
Nordi98 2025-07-31 07:35:56 +02:00
parent 16b0058156
commit 3279494318
3 changed files with 193 additions and 168 deletions

View file

@ -2,12 +2,12 @@ local QBCore = exports['qb-core']:GetCoreObject()
local stationVehicles = {}
local stationBlips = {}

print("^2[TAXI STATIONS DEBUG]^7 Stations script loaded")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Stations script loaded")

-- Taxi Stationen initialisieren
CreateThread(function()
Wait(5000) -- Längere Wartezeit, um sicherzustellen, dass alle Ressourcen geladen sind
print("^2[TAXI STATIONS DEBUG]^7 Initializing taxi stations...")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Initializing taxi stations...")
InitializeTaxiStations()
-- Regelmäßige Überprüfung und Wiederherstellung der Stationen
@ -20,21 +20,21 @@ CreateThread(function()
end)

function InitializeTaxiStations()
print("^2[TAXI STATIONS DEBUG]^7 InitializeTaxiStations started")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 InitializeTaxiStations started")
if not Config.TaxiStations then
print("^1[TAXI STATIONS DEBUG]^7 Config.TaxiStations not found!")
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Config.TaxiStations not found!")
return
end
print("^2[TAXI STATIONS DEBUG]^7 Found " .. #Config.TaxiStations .. " stations")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Found " .. #Config.TaxiStations .. " stations")
-- Zuerst alle bestehenden Fahrzeuge und Blips entfernen
CleanupExistingStations()
-- Dann neue erstellen
for stationId, station in pairs(Config.TaxiStations) do
print("^2[TAXI STATIONS DEBUG]^7 Processing station " .. stationId .. ": " .. station.name)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Processing station " .. stationId .. ": " .. station.name)
-- Blip für Station erstellen
local blip = AddBlipForCoord(station.blipCoords.x, station.blipCoords.y, station.blipCoords.z)
@ -46,7 +46,7 @@ function InitializeTaxiStations()
AddTextComponentString(station.name)
EndTextCommandSetBlipName(blip)
stationBlips[stationId] = blip
print("^2[TAXI STATIONS DEBUG]^7 Blip created for station " .. stationId)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Blip created for station " .. stationId)
-- Fahrzeuge an Station spawnen
stationVehicles[stationId] = {}
@ -56,17 +56,17 @@ function InitializeTaxiStations()
for vehicleId, vehicleData in pairs(station.vehicles) do
-- Kleine Verzögerung zwischen jedem Fahrzeug
Wait(500)
print("^2[TAXI STATIONS DEBUG]^7 Spawning vehicle " .. vehicleId .. " (" .. vehicleData.model .. ") at station " .. stationId)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Spawning vehicle " .. vehicleId .. " (" .. vehicleData.model .. ") at station " .. stationId)
SpawnStationVehicle(stationId, vehicleId, vehicleData)
end
end)
end
print("^2[TAXI STATIONS DEBUG]^7 All stations initialization started")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 All stations initialization started")
end

function CleanupExistingStations()
print("^2[TAXI STATIONS DEBUG]^7 Cleaning up existing stations...")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Cleaning up existing stations...")
-- Alle bestehenden Fahrzeuge löschen
for stationId, vehicles in pairs(stationVehicles) do
@ -90,17 +90,17 @@ function CleanupExistingStations()
stationVehicles = {}
stationBlips = {}
print("^2[TAXI STATIONS DEBUG]^7 Cleanup completed")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Cleanup completed")
end

function SpawnStationVehicle(stationId, vehicleId, vehicleData)
print("^2[TAXI STATIONS DEBUG]^7 SpawnStationVehicle: " .. stationId .. "/" .. vehicleId)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 SpawnStationVehicle: " .. stationId .. "/" .. vehicleId)
-- Prüfen ob bereits ein Fahrzeug für diese Position existiert
if stationVehicles[stationId] and stationVehicles[stationId][vehicleId] and
stationVehicles[stationId][vehicleId].entity and
DoesEntityExist(stationVehicles[stationId][vehicleId].entity) then
print("^3[TAXI STATIONS DEBUG]^7 Vehicle already exists for this position, removing it first")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Vehicle already exists for this position, removing it first")
exports['qb-target']:RemoveTargetEntity(stationVehicles[stationId][vehicleId].entity)
DeleteEntity(stationVehicles[stationId][vehicleId].entity)
end
@ -112,7 +112,7 @@ function SpawnStationVehicle(stationId, vehicleId, vehicleData)
local vehCoords = GetEntityCoords(vehicle)
if #(vector3(vehicleData.coords.x, vehicleData.coords.y, vehicleData.coords.z) - vehCoords) < 3.0 then
clearArea = false
print("^3[TAXI STATIONS DEBUG]^7 Position blocked by another vehicle, will retry later")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Position blocked by another vehicle, will retry later")
-- Nach 30 Sekunden erneut versuchen
SetTimeout(30000, function()
SpawnStationVehicle(stationId, vehicleId, vehicleData)
@ -123,17 +123,17 @@ function SpawnStationVehicle(stationId, vehicleId, vehicleData)
CreateThread(function()
local vehicleHash = GetHashKey(vehicleData.model)
print("^2[TAXI STATIONS DEBUG]^7 Vehicle hash: " .. vehicleHash)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Vehicle hash: " .. vehicleHash)
RequestModel(vehicleHash)
local timeout = GetGameTimer() + 10000
while not HasModelLoaded(vehicleHash) and GetGameTimer() < timeout do
print("^3[TAXI STATIONS DEBUG]^7 Waiting for model " .. vehicleData.model .. " to load...")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Waiting for model " .. vehicleData.model .. " to load...")
Wait(100)
end
if not HasModelLoaded(vehicleHash) then
print("^1[TAXI STATIONS DEBUG]^7 Failed to load model: " .. vehicleData.model)
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Failed to load model: " .. vehicleData.model)
-- Nach 30 Sekunden erneut versuchen
SetTimeout(30000, function()
SpawnStationVehicle(stationId, vehicleId, vehicleData)
@ -152,7 +152,7 @@ function SpawnStationVehicle(stationId, vehicleId, vehicleData)
)
if not DoesEntityExist(vehicle) then
print("^1[TAXI STATIONS DEBUG]^7 Failed to create vehicle!")
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Failed to create vehicle!")
-- Nach 30 Sekunden erneut versuchen
SetTimeout(30000, function()
SpawnStationVehicle(stationId, vehicleId, vehicleData)
@ -160,7 +160,7 @@ function SpawnStationVehicle(stationId, vehicleId, vehicleData)
return
end
print("^2[TAXI STATIONS DEBUG]^7 Vehicle created: " .. vehicle)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Vehicle created: " .. vehicle)
-- Fahrzeug konfigurieren
SetEntityAsMissionEntity(vehicle, true, true)
@ -187,7 +187,7 @@ function SpawnStationVehicle(stationId, vehicleId, vehicleData)
occupied = false
}
print("^2[TAXI STATIONS DEBUG]^7 Adding qb-target for vehicle " .. vehicle)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Adding qb-target for vehicle " .. vehicle)
-- qb-target für Fahrzeug hinzufügen
exports['qb-target']:AddTargetEntity(vehicle, {
@ -204,14 +204,14 @@ function SpawnStationVehicle(stationId, vehicleId, vehicleData)
distance = 3.0
})
print("^2[TAXI STATIONS DEBUG]^7 qb-target added for vehicle " .. vehicle)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 qb-target added for vehicle " .. vehicle)
SetModelAsNoLongerNeeded(vehicleHash)
end)
end

function CheckAndRestoreStationVehicles()
print("^2[TAXI STATIONS DEBUG]^7 Checking station vehicles...")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Checking station vehicles...")
local restoredCount = 0
@ -225,22 +225,22 @@ function CheckAndRestoreStationVehicles()
-- Prüfen ob das Fahrzeug existiert
if not stationVehicles[stationId][vehicleId] then
print("^3[TAXI STATIONS DEBUG]^7 Vehicle data missing for station " .. stationId .. ", vehicle " .. vehicleId)
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Vehicle data missing for station " .. stationId .. ", vehicle " .. vehicleId)
shouldSpawn = true
elseif not stationVehicles[stationId][vehicleId].entity then
print("^3[TAXI STATIONS DEBUG]^7 Vehicle entity missing for station " .. stationId .. ", vehicle " .. vehicleId)
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Vehicle entity missing for station " .. stationId .. ", vehicle " .. vehicleId)
shouldSpawn = true
elseif not DoesEntityExist(stationVehicles[stationId][vehicleId].entity) then
print("^3[TAXI STATIONS DEBUG]^7 Vehicle entity doesn't exist for station " .. stationId .. ", vehicle " .. vehicleId)
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Vehicle entity doesn't exist for station " .. stationId .. ", vehicle " .. vehicleId)
shouldSpawn = true
elseif stationVehicles[stationId][vehicleId].occupied then
-- Fahrzeug ist besetzt, nicht neu spawnen
print("^2[TAXI STATIONS DEBUG]^7 Vehicle at station " .. stationId .. ", vehicle " .. vehicleId .. " is occupied")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Vehicle at station " .. stationId .. ", vehicle " .. vehicleId .. " is occupied")
shouldSpawn = false
end
if shouldSpawn then
print("^2[TAXI STATIONS DEBUG]^7 Respawning vehicle at station " .. stationId .. ", vehicle " .. vehicleId)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Respawning vehicle at station " .. stationId .. ", vehicle " .. vehicleId)
SpawnStationVehicle(stationId, vehicleId, vehicleData)
restoredCount = restoredCount + 1
@ -251,9 +251,9 @@ function CheckAndRestoreStationVehicles()
end
if restoredCount > 0 then
print("^2[TAXI STATIONS DEBUG]^7 Restored " .. restoredCount .. " station vehicles")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Restored " .. restoredCount .. " station vehicles")
else
print("^2[TAXI STATIONS DEBUG]^7 All station vehicles are present")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 All station vehicles are present")
end
end

@ -261,7 +261,7 @@ end
function InitializeTaxiDriverAI(driver, vehicle)
if not driver or not DoesEntityExist(driver) then return end
print("^2[TAXI STATIONS DEBUG]^7 Initializing advanced taxi driver AI")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Initializing advanced taxi driver AI")
-- Fahrer-Persönlichkeit und Fähigkeiten zufällig festlegen
local driverData = {
@ -344,14 +344,14 @@ function InitializeTaxiDriverAI(driver, vehicle)
-- Gerade an Ampel angekommen
driverData.state.isWaitingAtTrafficLight = true
driverData.state.trafficLightWaitStart = currentTime
print("^3[TAXI STATIONS DEBUG]^7 Taxi waiting at traffic light")
DebugPrint("^3[TAXI STATIONS 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 STATIONS DEBUG]^7 Taxi waited too long at traffic light, trying to continue")
DebugPrint("^3[TAXI STATIONS 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)
@ -362,7 +362,7 @@ function InitializeTaxiDriverAI(driver, vehicle)
elseif not isAtTrafficLight and driverData.state.isWaitingAtTrafficLight then
-- Ampel verlassen
driverData.state.isWaitingAtTrafficLight = false
print("^2[TAXI STATIONS DEBUG]^7 Taxi continued after traffic light")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Taxi continued after traffic light")
end
-- Steckenbleiben-Erkennung (nicht an Ampel und kaum Bewegung)
@ -371,14 +371,14 @@ function InitializeTaxiDriverAI(driver, vehicle)
-- Nur alle 5 Zähler-Erhöhungen loggen
if driverData.state.stuckCounter % 5 == 0 then
print("^3[TAXI STATIONS DEBUG]^7 Taxi might be stuck: " .. driverData.state.stuckCounter .. "/" .. driverData.settings.maxStuckCounter)
DebugPrint("^3[TAXI STATIONS 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 STATIONS DEBUG]^7 Taxi is stuck, attempting intelligent recovery")
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Taxi is stuck, attempting intelligent recovery")
driverData.state.lastStuckRecovery = currentTime
driverData.state.currentBehavior = "recovery"
@ -401,7 +401,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 STATIONS DEBUG]^7 Taxi moving too slow, recalculating route")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Taxi moving too slow, recalculating route")
driverData.state.lastRouteRecalculation = currentTime
-- Route neu berechnen
@ -449,17 +449,17 @@ function TaxiDriverIntelligentRecovery(driver, vehicle)
if backwardClear then
-- Rückwärts fahren wenn hinten frei
print("^3[TAXI STATIONS DEBUG]^7 Recovery: Backing up")
DebugPrint("^3[TAXI STATIONS 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 STATIONS DEBUG]^7 Recovery: Path clear, continuing")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Recovery: Path clear, continuing")
TaxiDriverContinueRoute(driver, vehicle)
else
-- Sonst versuchen zu wenden
print("^3[TAXI STATIONS DEBUG]^7 Recovery: Turning around")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Recovery: Turning around")
TaskVehicleTempAction(driver, vehicle, 7, 2000) -- Turn left
Wait(1000)
TaskVehicleTempAction(driver, vehicle, 8, 1000) -- Reverse
@ -470,13 +470,13 @@ function TaxiDriverIntelligentRecovery(driver, vehicle)
end
elseif forwardClear then
-- Wenn nur vorne frei, vorwärts fahren
print("^3[TAXI STATIONS DEBUG]^7 Recovery: Moving forward")
DebugPrint("^3[TAXI STATIONS 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 STATIONS DEBUG]^7 Recovery: Trying to wiggle free")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Recovery: Trying to wiggle free")
TaskVehicleTempAction(driver, vehicle, 7, 1000) -- Turn left
Wait(1000)
TaskVehicleTempAction(driver, vehicle, 8, 800) -- Reverse
@ -499,7 +499,7 @@ function TaxiDriverRecalculateRoute(driver, vehicle)
if destination then
-- Versuche einen alternativen Weg zu finden
print("^3[TAXI STATIONS DEBUG]^7 Recalculating route to destination")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Recalculating route to destination")
-- Kurz anhalten
TaskVehicleTempAction(driver, vehicle, 27, 1000) -- Stop
@ -602,14 +602,14 @@ end

-- Event für Einsteigen in Station-Taxi
RegisterNetEvent('taxi:enterStationVehicle', function(data)
print("^2[TAXI STATIONS DEBUG]^7 Player trying to enter station vehicle")
print("^2[TAXI STATIONS DEBUG]^7 Data: " .. json.encode(data))
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Player trying to enter station vehicle")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Data: " .. json.encode(data))
local stationId = data.stationId
local vehicleId = data.vehicleId
if not stationVehicles[stationId] or not stationVehicles[stationId][vehicleId] then
print("^1[TAXI STATIONS DEBUG]^7 Vehicle not found in data")
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Vehicle not found in data")
lib.notify({
title = 'Taxi Service',
description = 'Dieses Taxi ist nicht verfügbar',
@ -621,7 +621,7 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
local vehicleInfo = stationVehicles[stationId][vehicleId]
if vehicleInfo.occupied then
print("^1[TAXI STATIONS DEBUG]^7 Vehicle already occupied")
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Vehicle already occupied")
lib.notify({
title = 'Taxi Service',
description = 'Dieses Taxi ist bereits besetzt',
@ -630,7 +630,7 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
return
end
print("^2[TAXI STATIONS DEBUG]^7 Entering vehicle...")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Entering vehicle...")
-- Spieler ins Fahrzeug setzen
local playerPed = PlayerPedId()
@ -639,7 +639,7 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
-- Türen entsperren
SetVehicleDoorsLocked(vehicle, 1)
-- Info-Text anzeigen während Fahrer geladen wird
print("^2[TAXI STATIONS DEBUG]^7 Showing driver loading text...")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Showing driver loading text...")
lib.showTextUI('🚕 Warte an der Station - Fahrer wird geladen...', {
position = "top-center",
icon = 'taxi',
@ -669,7 +669,7 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
local driverHash = nil
for i, modelName in pairs(driverModels) do
print("^2[TAXI STATIONS DEBUG]^7 Trying driver model " .. i .. ": " .. modelName)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Trying driver model " .. i .. ": " .. modelName)
driverHash = GetHashKey(modelName)
-- Text während Model-Loading aktualisieren
@ -690,13 +690,13 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
while not HasModelLoaded(driverHash) and GetGameTimer() < timeout do
attempts = attempts + 1
if attempts % 10 == 0 then
print("^3[TAXI STATIONS DEBUG]^7 Still waiting for model " .. modelName .. " (attempt " .. attempts .. ")")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Still waiting for model " .. modelName .. " (attempt " .. attempts .. ")")
end
Wait(100)
end
if HasModelLoaded(driverHash) then
print("^2[TAXI STATIONS DEBUG]^7 Driver model " .. modelName .. " loaded successfully")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Driver model " .. modelName .. " loaded successfully")
-- Text aktualisieren
lib.showTextUI('🚕 Erstelle Fahrer...', {
@ -712,14 +712,14 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
driver = CreatePedInsideVehicle(vehicle, 26, driverHash, -1, true, false)
if DoesEntityExist(driver) then
print("^2[TAXI STATIONS DEBUG]^7 Driver created successfully: " .. driver)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Driver created successfully: " .. driver)
break
else
print("^1[TAXI STATIONS DEBUG]^7 Failed to create driver with model: " .. modelName)
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Failed to create driver with model: " .. modelName)
SetModelAsNoLongerNeeded(driverHash)
end
else
print("^1[TAXI STATIONS DEBUG]^7 Failed to load driver model: " .. modelName)
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Failed to load driver model: " .. modelName)
SetModelAsNoLongerNeeded(driverHash)
end
@ -728,7 +728,7 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
-- Fallback: Notfall-Fahrer erstellen
if not driver or not DoesEntityExist(driver) then
print("^3[TAXI STATIONS DEBUG]^7 Using emergency fallback driver creation...")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Using emergency fallback driver creation...")
lib.showTextUI('🚕 Erstelle Notfall-Fahrer...', {
position = "top-center",
@ -758,7 +758,7 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
if HasModelLoaded(hash) then
driver = CreatePedInsideVehicle(vehicle, 26, hash, -1, true, false)
if DoesEntityExist(driver) then
print("^2[TAXI STATIONS DEBUG]^7 Emergency driver created")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Emergency driver created")
driverHash = hash
break
end
@ -771,7 +771,7 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
-- Wenn immer noch kein Fahrer, ohne Fahrer fortfahren
if not driver or not DoesEntityExist(driver) then
print("^1[TAXI STATIONS DEBUG]^7 Could not create any driver, continuing without driver")
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Could not create any driver, continuing without driver")
lib.showTextUI('❌ Kein Fahrer verfügbar - Du kannst selbst fahren', {
position = "top-center",
@ -849,11 +849,11 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
-- Ersten verfügbaren Hintersitz wählen
if #availableSeats > 0 then
seatIndex = availableSeats[1]
print("^2[TAXI STATIONS DEBUG]^7 Using rear seat: " .. seatIndex)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Using rear seat: " .. seatIndex)
else
-- Fallback: Beifahrersitz
seatIndex = 0
print("^3[TAXI STATIONS DEBUG]^7 No rear seats available, using passenger seat")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 No rear seats available, using passenger seat")
end
-- Spieler in den gewählten Sitz einsteigen lassen
@ -884,14 +884,14 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
-- Info-Text verstecken
lib.hideTextUI()
print("^2[TAXI STATIONS DEBUG]^7 Player entered successfully")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Player entered successfully")
-- Prüfen ob Spieler wirklich hinten sitzt
local playerSeat = GetPlayerVehicleSeat(playerPed, vehicle)
print("^2[TAXI STATIONS DEBUG]^7 Player is in seat: " .. tostring(playerSeat))
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Player is in seat: " .. tostring(playerSeat))
if playerSeat == -1 then -- Fahrersitz
print("^3[TAXI STATIONS DEBUG]^7 Player is in driver seat, moving to passenger area")
DebugPrint("^3[TAXI STATIONS DEBUG]^7 Player is in driver seat, moving to passenger area")
if driver and DoesEntityExist(driver) then
-- Spieler zum nächsten verfügbaren Sitz bewegen
@ -916,7 +916,7 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
end
if not hasEntered then
print("^1[TAXI STATIONS DEBUG]^7 Player failed to enter vehicle")
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Player failed to enter vehicle")
-- Info-Text verstecken
lib.hideTextUI()
@ -938,7 +938,7 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
end)

function OpenStationTaxiMenu(stationId, vehicleId, vehicle, driver, pricePerKm)
print("^2[TAXI STATIONS DEBUG]^7 Opening station taxi menu")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Opening station taxi menu")
local options = {}
@ -1020,7 +1020,7 @@ function OpenStationTaxiMenu(stationId, vehicleId, vehicle, driver, pricePerKm)
end

function SelfDriveStationTaxi(stationId, vehicleId, vehicle)
print("^2[TAXI STATIONS DEBUG]^7 Player driving taxi themselves")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Player driving taxi themselves")
local playerPed = PlayerPedId()
@ -1040,7 +1040,7 @@ function SelfDriveStationTaxi(stationId, vehicleId, vehicle)
-- Prüfen ob Spieler noch im Fahrzeug ist
if not IsPedInVehicle(playerPed, vehicle, false) then
print("^2[TAXI STATIONS DEBUG]^7 Player left self-drive taxi")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Player left self-drive taxi")
-- Nach 30 Sekunden Taxi zurück zur Station
SetTimeout(30000, function()
@ -1055,7 +1055,7 @@ function SelfDriveStationTaxi(stationId, vehicleId, vehicle)
end

function OpenStationSelectionMenu(stationId, vehicleId, vehicle, driver, pricePerKm)
print("^2[TAXI STATIONS DEBUG]^7 Opening station selection menu")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Opening station selection menu")
local options = {}
@ -1095,7 +1095,7 @@ function OpenStationSelectionMenu(stationId, vehicleId, vehicle, driver, pricePe
end

function StartStationTaxiRide(stationId, vehicleId, vehicle, driver, destination, price)
print("^2[TAXI STATIONS DEBUG]^7 Starting station taxi ride to: " .. tostring(destination.x) .. ", " .. tostring(destination.y) .. ", " .. tostring(destination.z))
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Starting station taxi ride to: " .. tostring(destination.x) .. ", " .. tostring(destination.y) .. ", " .. tostring(destination.z))
-- Wenn kein Fahrer, Spieler selbst fahren lassen
if not driver or not DoesEntityExist(driver) then
@ -1179,7 +1179,7 @@ function StartStationTaxiRide(stationId, vehicleId, vehicle, driver, destination
-- Angekommen
TaskVehicleTempAction(driver, vehicle, 27, 3000)
print("^2[TAXI STATIONS DEBUG]^7 Arrived at destination")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Arrived at destination")
lib.notify({
title = 'Taxi Service',
description = 'Du bist angekommen! Preis: $' .. price,
@ -1220,7 +1220,7 @@ function StartStationTaxiRide(stationId, vehicleId, vehicle, driver, destination
-- Überprüfen ob die Fahrt zu lange dauert
if GetGameTimer() > rideTimeout then
print("^1[TAXI STATIONS DEBUG]^7 Taxi ride timed out!")
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Taxi ride timed out!")
lib.notify({
title = 'Taxi Service',
description = 'Die Fahrt dauert zu lange. Wir sind fast da!',
@ -1254,7 +1254,7 @@ function StartStationTaxiRide(stationId, vehicleId, vehicle, driver, destination
end

function ExitStationTaxi(stationId, vehicleId, vehicle, driver)
print("^2[TAXI STATIONS DEBUG]^7 Player exiting station taxi")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Player exiting station taxi")
local playerPed = PlayerPedId()
TaskLeaveVehicle(playerPed, vehicle, 0)
@ -1272,26 +1272,26 @@ function ExitStationTaxi(stationId, vehicleId, vehicle, driver)
end

function ReturnTaxiToStation(stationId, vehicleId, vehicle, driver)
print("^2[TAXI STATIONS DEBUG]^7 Returning taxi to station: " .. stationId .. "/" .. vehicleId)
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Returning taxi to station: " .. stationId .. "/" .. vehicleId)
if not stationVehicles[stationId] or not stationVehicles[stationId][vehicleId] then
print("^1[TAXI STATIONS DEBUG]^7 Station vehicle data not found for return")
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Station vehicle data not found for return")
return
end
if not DoesEntityExist(vehicle) then
print("^1[TAXI STATIONS DEBUG]^7 Vehicle doesn't exist anymore")
DebugPrint("^1[TAXI STATIONS DEBUG]^7 Vehicle doesn't exist anymore")
-- Fahrzeug als nicht besetzt markieren
stationVehicles[stationId][vehicleId].occupied = false
stationVehicles[stationId][vehicleId].driver = nil
stationVehicles[stationId][vehicleId].entity = nil
-- Nach Respawn-Zeit neues Fahrzeug spawnen
print("^2[TAXI STATIONS DEBUG]^7 Scheduling respawn in " .. Config.StationTaxiRespawnTime .. " seconds")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Scheduling respawn in " .. Config.StationTaxiRespawnTime .. " seconds")
SetTimeout(Config.StationTaxiRespawnTime * 1000, function()
if stationVehicles[stationId] and stationVehicles[stationId][vehicleId] then
local vehicleData = stationVehicles[stationId][vehicleId].data
print("^2[TAXI STATIONS DEBUG]^7 Respawning vehicle at station")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Respawning vehicle at station")
SpawnStationVehicle(stationId, vehicleId, vehicleData)
end
end)
@ -1300,7 +1300,7 @@ function ReturnTaxiToStation(stationId, vehicleId, vehicle, driver)
-- Wenn Fahrer existiert, Taxi zur Station zurückfahren lassen
if driver and DoesEntityExist(driver) then
print("^2[TAXI STATIONS DEBUG]^7 Making taxi drive back to station")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Making taxi drive back to station")
-- Zufällige Position in der Nähe der Station finden
local stationCoords = Config.TaxiStations[stationId].coords
@ -1317,13 +1317,13 @@ function ReturnTaxiToStation(stationId, vehicleId, vehicle, driver)
-- Fahrer löschen
if driver and DoesEntityExist(driver) then
DeleteEntity(driver)
print("^2[TAXI STATIONS DEBUG]^7 Driver deleted")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Driver deleted")
end
-- Fahrzeug löschen
if DoesEntityExist(vehicle) then
DeleteEntity(vehicle)
print("^2[TAXI STATIONS DEBUG]^7 Vehicle deleted")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Vehicle deleted")
end
-- Fahrzeug als nicht besetzt markieren
@ -1332,11 +1332,11 @@ function ReturnTaxiToStation(stationId, vehicleId, vehicle, driver)
stationVehicles[stationId][vehicleId].entity = nil
-- Nach Respawn-Zeit neues Fahrzeug spawnen
print("^2[TAXI STATIONS DEBUG]^7 Scheduling respawn in " .. Config.StationTaxiRespawnTime .. " seconds")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Scheduling respawn in " .. Config.StationTaxiRespawnTime .. " seconds")
SetTimeout(Config.StationTaxiRespawnTime * 1000, function()
if stationVehicles[stationId] and stationVehicles[stationId][vehicleId] then
local vehicleData = stationVehicles[stationId][vehicleId].data
print("^2[TAXI STATIONS DEBUG]^7 Respawning vehicle at station")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Respawning vehicle at station")
SpawnStationVehicle(stationId, vehicleId, vehicleData)
end
end)
@ -1347,7 +1347,7 @@ function ReturnTaxiToStation(stationId, vehicleId, vehicle, driver)
if DoesEntityExist(vehicle) then
exports['qb-target']:RemoveTargetEntity(vehicle)
DeleteEntity(vehicle)
print("^2[TAXI STATIONS DEBUG]^7 Vehicle deleted")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Vehicle deleted")
end
-- Fahrzeug als nicht besetzt markieren
@ -1356,11 +1356,11 @@ function ReturnTaxiToStation(stationId, vehicleId, vehicle, driver)
stationVehicles[stationId][vehicleId].entity = nil
-- Nach Respawn-Zeit neues Fahrzeug spawnen
print("^2[TAXI STATIONS DEBUG]^7 Scheduling respawn in " .. Config.StationTaxiRespawnTime .. " seconds")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Scheduling respawn in " .. Config.StationTaxiRespawnTime .. " seconds")
SetTimeout(Config.StationTaxiRespawnTime * 1000, function()
if stationVehicles[stationId] and stationVehicles[stationId][vehicleId] then
local vehicleData = stationVehicles[stationId][vehicleId].data
print("^2[TAXI STATIONS DEBUG]^7 Respawning vehicle at station")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Respawning vehicle at station")
SpawnStationVehicle(stationId, vehicleId, vehicleData)
end
end)
@ -1406,7 +1406,7 @@ end)

-- Event für Admin Respawn
RegisterNetEvent('taxi:respawnAllStations', function()
print("^2[TAXI STATIONS DEBUG]^7 Respawning all stations...")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Respawning all stations...")
-- Alle bestehenden Fahrzeuge löschen
for stationId, vehicles in pairs(stationVehicles) do
@ -1505,7 +1505,7 @@ end)

-- Funktion zum Beenden der Stations-Taxi Fahrt
function EndStationTaxiRide(stationId, vehicleId, vehicle, driver)
print("^2[TAXI STATIONS DEBUG]^7 Ending station taxi ride")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Ending station taxi ride")
if not vehicle or not DoesEntityExist(vehicle) then
return
@ -1544,7 +1544,7 @@ end
-- Cleanup beim Resource Stop
AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then
print("^2[TAXI STATIONS DEBUG]^7 Cleaning up stations...")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 Cleaning up stations...")
-- TextUI verstecken falls noch angezeigt
lib.hideTextUI()
@ -1567,10 +1567,21 @@ AddEventHandler('onResourceStop', function(resourceName)
RemoveBlip(blip)
end
print("^2[TAXI STATIONS DEBUG]^7 Cleanup completed")
DebugPrint("^2[TAXI STATIONS DEBUG]^7 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
orint("^2[TAXI DEBUG]^7 " .. message)
end
end
end