forked from Simnation/Main
ed
This commit is contained in:
parent
395693bac1
commit
774d8834c2
1 changed files with 110 additions and 17 deletions
|
@ -157,6 +157,17 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
|
|||
-- Türen entsperren
|
||||
SetVehicleDoorsLocked(vehicle, 1)
|
||||
|
||||
-- Info-Text anzeigen während Fahrer geladen wird
|
||||
lib.showTextUI('🚕 Fahrer ist noch aufm Pott, bitte warte kurz...', {
|
||||
position = "top-center",
|
||||
icon = 'taxi',
|
||||
style = {
|
||||
borderRadius = 10,
|
||||
backgroundColor = '#48BB78',
|
||||
color = 'white'
|
||||
}
|
||||
})
|
||||
|
||||
-- Verschiedene Fahrer-Models versuchen
|
||||
local driverModels = {
|
||||
"a_m_m_taxi_01",
|
||||
|
@ -215,10 +226,19 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
|
|||
end
|
||||
end
|
||||
|
||||
-- Info-Text verstecken
|
||||
lib.hideTextUI()
|
||||
|
||||
-- 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")
|
||||
driver = nil
|
||||
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Kein Fahrer verfügbar - Du kannst das Taxi selbst fahren',
|
||||
type = 'warning'
|
||||
})
|
||||
else
|
||||
-- Fahrer konfigurieren
|
||||
SetEntityAsMissionEntity(driver, true, true)
|
||||
|
@ -234,34 +254,109 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
|
|||
SetPedComponentVariation(driver, 11, 0, 0, 0) -- Jacket
|
||||
SetPedComponentVariation(driver, 4, 0, 0, 0) -- Pants
|
||||
SetPedComponentVariation(driver, 6, 0, 0, 0) -- Shoes
|
||||
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Fahrer bereit - Steige hinten ein',
|
||||
type = 'success'
|
||||
})
|
||||
end
|
||||
|
||||
-- Spieler einsteigen lassen
|
||||
TaskEnterVehicle(playerPed, vehicle, 10000, 0, 1.0, 1, 0)
|
||||
-- Spieler HINTEN einsteigen lassen
|
||||
local seatIndex = -1 -- Hinten rechts
|
||||
|
||||
-- Prüfen welche Hintersitze verfügbar sind
|
||||
local availableSeats = {}
|
||||
for i = 1, 3 do -- Sitze 1, 2, 3 (hinten links, hinten mitte, hinten rechts)
|
||||
if not IsVehicleSeatFree(vehicle, i) == false then
|
||||
table.insert(availableSeats, i)
|
||||
end
|
||||
end
|
||||
|
||||
-- Ersten verfügbaren Hintersitz wählen
|
||||
if #availableSeats > 0 then
|
||||
seatIndex = availableSeats[1]
|
||||
print("^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")
|
||||
end
|
||||
|
||||
-- Spieler in den gewählten Sitz einsteigen lassen
|
||||
TaskEnterVehicle(playerPed, vehicle, 10000, seatIndex, 1.0, 1, 0)
|
||||
|
||||
-- Info-Text während Einsteigen
|
||||
lib.showTextUI('🚕 Steige ins Taxi ein...', {
|
||||
position = "top-center",
|
||||
icon = 'car-side',
|
||||
style = {
|
||||
borderRadius = 10,
|
||||
backgroundColor = '#4299E1',
|
||||
color = 'white'
|
||||
}
|
||||
})
|
||||
|
||||
-- Warten bis Spieler eingestiegen ist
|
||||
CreateThread(function()
|
||||
local enterTimeout = GetGameTimer() + 10000
|
||||
while GetGameTimer() < enterTimeout do
|
||||
local enterTimeout = GetGameTimer() + 15000 -- Längere Zeit für Einsteigen
|
||||
local hasEntered = false
|
||||
|
||||
while GetGameTimer() < enterTimeout and not hasEntered do
|
||||
if IsPedInVehicle(playerPed, vehicle, false) then
|
||||
hasEntered = true
|
||||
vehicleInfo.occupied = true
|
||||
vehicleInfo.driver = driver
|
||||
|
||||
print("^2[TAXI STATIONS DEBUG]^7 Player entered, opening menu")
|
||||
-- Info-Text verstecken
|
||||
lib.hideTextUI()
|
||||
|
||||
print("^2[TAXI STATIONS DEBUG]^7 Player entered successfully")
|
||||
|
||||
-- Prüfen ob Spieler wirklich hinten sitzt
|
||||
local playerSeat = GetPedVehicleSeat(playerPed)
|
||||
if playerSeat == -1 then -- Fahrersitz
|
||||
print("^3[TAXI STATIONS DEBUG]^7 Player is in driver seat, moving to passenger area")
|
||||
|
||||
if driver and DoesEntityExist(driver) then
|
||||
-- Spieler zum Beifahrersitz bewegen
|
||||
TaskShuffleToNextVehicleSeat(playerPed, vehicle)
|
||||
Wait(2000)
|
||||
end
|
||||
end
|
||||
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Willkommen im Taxi! Wähle dein Ziel.',
|
||||
type = 'success'
|
||||
})
|
||||
|
||||
-- Ziel-Menu öffnen
|
||||
Wait(1000) -- Kurz warten damit Einsteigen abgeschlossen ist
|
||||
OpenStationTaxiMenu(stationId, vehicleId, vehicle, driver, vehicleInfo.data.pricePerKm)
|
||||
break
|
||||
end
|
||||
Wait(100)
|
||||
end
|
||||
|
||||
if not IsPedInVehicle(playerPed, vehicle, false) then
|
||||
if not hasEntered then
|
||||
print("^1[TAXI STATIONS DEBUG]^7 Player failed to enter vehicle")
|
||||
|
||||
-- Info-Text verstecken
|
||||
lib.hideTextUI()
|
||||
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Einsteigen fehlgeschlagen',
|
||||
type = 'error'
|
||||
})
|
||||
|
||||
-- Cleanup
|
||||
if driver and DoesEntityExist(driver) then
|
||||
DeleteEntity(driver)
|
||||
end
|
||||
SetVehicleDoorsLocked(vehicle, 2)
|
||||
vehicleInfo.occupied = false
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
@ -563,8 +658,8 @@ function CalculateDistanceToCoords(coords)
|
|||
return #(playerCoords - coords)
|
||||
end
|
||||
|
||||
-- Zusätzliche Funktionen für bessere Verwaltung
|
||||
function GetNearestTaxiStation()
|
||||
-- Command um nächste Taxi-Station zu finden
|
||||
RegisterCommand('nearesttaxi', function()
|
||||
local playerCoords = GetEntityCoords(PlayerPedId())
|
||||
local nearestStation = nil
|
||||
local nearestDistance = math.huge
|
||||
|
@ -577,21 +672,15 @@ function GetNearestTaxiStation()
|
|||
end
|
||||
end
|
||||
|
||||
return nearestStation
|
||||
end
|
||||
|
||||
-- Command um nächste Taxi-Station zu finden
|
||||
RegisterCommand('nearesttaxi', function()
|
||||
local nearest = GetNearestTaxiStation()
|
||||
if nearest then
|
||||
if nearestStation then
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
description = 'Nächste Station: ' .. nearest.data.name .. ' (' .. math.ceil(nearest.distance) .. 'm)',
|
||||
description = 'Nächste Station: ' .. nearestStation.data.name .. ' (' .. math.ceil(nearestStation.distance) .. 'm)',
|
||||
type = 'info'
|
||||
})
|
||||
|
||||
-- Waypoint zur nächsten Station setzen
|
||||
SetNewWaypoint(nearest.data.blipCoords.x, nearest.data.blipCoords.y)
|
||||
SetNewWaypoint(nearestStation.data.blipCoords.x, nearestStation.data.blipCoords.y)
|
||||
else
|
||||
lib.notify({
|
||||
title = 'Taxi Service',
|
||||
|
@ -643,6 +732,9 @@ AddEventHandler('onResourceStop', function(resourceName)
|
|||
if GetCurrentResourceName() == resourceName then
|
||||
print("^2[TAXI STATIONS DEBUG]^7 Cleaning up stations...")
|
||||
|
||||
-- TextUI verstecken falls noch angezeigt
|
||||
lib.hideTextUI()
|
||||
|
||||
-- Alle Station-Fahrzeuge löschen
|
||||
for stationId, vehicles in pairs(stationVehicles) do
|
||||
for vehicleId, vehicleInfo in pairs(vehicles) do
|
||||
|
@ -664,3 +756,4 @@ AddEventHandler('onResourceStop', function(resourceName)
|
|||
print("^2[TAXI STATIONS DEBUG]^7 Cleanup completed")
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue