diff --git a/resources/[tools]/nordi_taxi/client/main.lua b/resources/[tools]/nordi_taxi/client/main.lua index 6b47529e6..f2d077bd1 100644 --- a/resources/[tools]/nordi_taxi/client/main.lua +++ b/resources/[tools]/nordi_taxi/client/main.lua @@ -794,6 +794,7 @@ RegisterCommand('stoptaxi', function() end end) + -- Thread zum Überwachen der Tasten im Taxi CreateThread(function() while true do diff --git a/resources/[tools]/nordi_taxi/client/stations.lua b/resources/[tools]/nordi_taxi/client/stations.lua index 66a3832f1..45f555853 100644 --- a/resources/[tools]/nordi_taxi/client/stations.lua +++ b/resources/[tools]/nordi_taxi/client/stations.lua @@ -1,4 +1,4 @@ -local QBCore = exports['qb-core']:GetCoreObject() +#local QBCore = exports['qb-core']:GetCoreObject() local stationVehicles = {} local stationBlips = {} @@ -905,6 +905,108 @@ RegisterNetEvent('taxi:respawnAllStations', function() }) end) + +-- Thread zum Überwachen der Tasten im Stations-Taxi +CreateThread(function() + while true do + Wait(0) + + local playerPed = PlayerPedId() + local inStationTaxi = false + local currentStationTaxi = nil + local currentStationId = nil + local currentVehicleId = nil + local currentDriver = nil + local pricePerKm = 0 + + -- Prüfen ob Spieler in einem Stations-Taxi sitzt + for stationId, vehicles in pairs(stationVehicles) do + for vehicleId, vehicleInfo in pairs(vehicles) do + if vehicleInfo.entity and DoesEntityExist(vehicleInfo.entity) and vehicleInfo.occupied then + if IsPedInVehicle(playerPed, vehicleInfo.entity, false) then + inStationTaxi = true + currentStationTaxi = vehicleInfo.entity + currentStationId = stationId + currentVehicleId = vehicleId + currentDriver = vehicleInfo.driver + pricePerKm = vehicleInfo.data.pricePerKm + break + end + end + end + if inStationTaxi then break end + end + + if inStationTaxi and currentStationTaxi then + -- Zeige Hinweise an + local helpText = '[E] - Ziel wählen [F] - Fahrt beenden' + lib.showTextUI(helpText, { + position = "top-center", + icon = 'taxi', + style = { + borderRadius = 10, + backgroundColor = '#48BB78', + color = 'white' + } + }) + + -- Wenn E gedrückt wird, öffne Menü + if IsControlJustReleased(0, 38) then -- E Taste + OpenStationTaxiMenu(currentStationId, currentVehicleId, currentStationTaxi, currentDriver, pricePerKm) + end + + -- Wenn F gedrückt wird, beende Fahrt + if IsControlJustReleased(0, 23) then -- F Taste + lib.hideTextUI() + EndStationTaxiRide(currentStationId, currentVehicleId, currentStationTaxi, currentDriver) + end + else + -- Nicht in einem Stations-Taxi + Wait(1000) + end + end +end) + +-- Funktion zum Beenden der Stations-Taxi Fahrt +function EndStationTaxiRide(stationId, vehicleId, vehicle, driver) + print("^2[TAXI STATIONS DEBUG]^7 Ending station taxi ride") + + if not vehicle or not DoesEntityExist(vehicle) then + return + end + + local playerPed = PlayerPedId() + + -- Fahrt beenden Benachrichtigung + lib.notify({ + title = 'Taxi Service', + description = 'Fahrt beendet. Du steigst aus.', + type = 'info' + }) + + -- Spieler aussteigen lassen + TaskLeaveVehicle(playerPed, vehicle, 0) + + -- Warten bis ausgestiegen + CreateThread(function() + local timeout = GetGameTimer() + 5000 + while GetGameTimer() < timeout do + if not IsPedInVehicle(playerPed, vehicle, false) then + -- Spieler ist ausgestiegen + break + end + Wait(100) + end + + -- Taxi nach 5 Sekunden zurück zur Station + SetTimeout(5000, function() + ReturnTaxiToStation(stationId, vehicleId, vehicle, driver) + end) + end) +end + + + -- Cleanup beim Resource Stop AddEventHandler('onResourceStop', function(resourceName) if GetCurrentResourceName() == resourceName then