1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-30 04:53:36 +02:00
parent 3ec4b4c27b
commit 5c935df3a3
2 changed files with 104 additions and 1 deletions

View file

@ -794,6 +794,7 @@ RegisterCommand('stoptaxi', function()
end end
end) end)
-- Thread zum Überwachen der Tasten im Taxi -- Thread zum Überwachen der Tasten im Taxi
CreateThread(function() CreateThread(function()
while true do while true do

View file

@ -1,4 +1,4 @@
local QBCore = exports['qb-core']:GetCoreObject() #local QBCore = exports['qb-core']:GetCoreObject()
local stationVehicles = {} local stationVehicles = {}
local stationBlips = {} local stationBlips = {}
@ -905,6 +905,108 @@ RegisterNetEvent('taxi:respawnAllStations', function()
}) })
end) 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 -- Cleanup beim Resource Stop
AddEventHandler('onResourceStop', function(resourceName) AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then if GetCurrentResourceName() == resourceName then