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
|
-- Türen entsperren
|
||||||
SetVehicleDoorsLocked(vehicle, 1)
|
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
|
-- Verschiedene Fahrer-Models versuchen
|
||||||
local driverModels = {
|
local driverModels = {
|
||||||
"a_m_m_taxi_01",
|
"a_m_m_taxi_01",
|
||||||
|
@ -215,10 +226,19 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Info-Text verstecken
|
||||||
|
lib.hideTextUI()
|
||||||
|
|
||||||
-- Wenn immer noch kein Fahrer, ohne Fahrer fortfahren
|
-- Wenn immer noch kein Fahrer, ohne Fahrer fortfahren
|
||||||
if not driver or not DoesEntityExist(driver) then
|
if not driver or not DoesEntityExist(driver) then
|
||||||
print("^1[TAXI STATIONS DEBUG]^7 Could not create any driver, continuing without driver")
|
print("^1[TAXI STATIONS DEBUG]^7 Could not create any driver, continuing without driver")
|
||||||
driver = nil
|
driver = nil
|
||||||
|
|
||||||
|
lib.notify({
|
||||||
|
title = 'Taxi Service',
|
||||||
|
description = 'Kein Fahrer verfügbar - Du kannst das Taxi selbst fahren',
|
||||||
|
type = 'warning'
|
||||||
|
})
|
||||||
else
|
else
|
||||||
-- Fahrer konfigurieren
|
-- Fahrer konfigurieren
|
||||||
SetEntityAsMissionEntity(driver, true, true)
|
SetEntityAsMissionEntity(driver, true, true)
|
||||||
|
@ -234,34 +254,109 @@ RegisterNetEvent('taxi:enterStationVehicle', function(data)
|
||||||
SetPedComponentVariation(driver, 11, 0, 0, 0) -- Jacket
|
SetPedComponentVariation(driver, 11, 0, 0, 0) -- Jacket
|
||||||
SetPedComponentVariation(driver, 4, 0, 0, 0) -- Pants
|
SetPedComponentVariation(driver, 4, 0, 0, 0) -- Pants
|
||||||
SetPedComponentVariation(driver, 6, 0, 0, 0) -- Shoes
|
SetPedComponentVariation(driver, 6, 0, 0, 0) -- Shoes
|
||||||
|
|
||||||
|
lib.notify({
|
||||||
|
title = 'Taxi Service',
|
||||||
|
description = 'Fahrer bereit - Steige hinten ein',
|
||||||
|
type = 'success'
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Spieler einsteigen lassen
|
-- Spieler HINTEN einsteigen lassen
|
||||||
TaskEnterVehicle(playerPed, vehicle, 10000, 0, 1.0, 1, 0)
|
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
|
-- Warten bis Spieler eingestiegen ist
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
local enterTimeout = GetGameTimer() + 10000
|
local enterTimeout = GetGameTimer() + 15000 -- Längere Zeit für Einsteigen
|
||||||
while GetGameTimer() < enterTimeout do
|
local hasEntered = false
|
||||||
|
|
||||||
|
while GetGameTimer() < enterTimeout and not hasEntered do
|
||||||
if IsPedInVehicle(playerPed, vehicle, false) then
|
if IsPedInVehicle(playerPed, vehicle, false) then
|
||||||
|
hasEntered = true
|
||||||
vehicleInfo.occupied = true
|
vehicleInfo.occupied = true
|
||||||
vehicleInfo.driver = driver
|
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
|
-- Ziel-Menu öffnen
|
||||||
|
Wait(1000) -- Kurz warten damit Einsteigen abgeschlossen ist
|
||||||
OpenStationTaxiMenu(stationId, vehicleId, vehicle, driver, vehicleInfo.data.pricePerKm)
|
OpenStationTaxiMenu(stationId, vehicleId, vehicle, driver, vehicleInfo.data.pricePerKm)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
Wait(100)
|
Wait(100)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not IsPedInVehicle(playerPed, vehicle, false) then
|
if not hasEntered then
|
||||||
print("^1[TAXI STATIONS DEBUG]^7 Player failed to enter vehicle")
|
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
|
-- Cleanup
|
||||||
if driver and DoesEntityExist(driver) then
|
if driver and DoesEntityExist(driver) then
|
||||||
DeleteEntity(driver)
|
DeleteEntity(driver)
|
||||||
end
|
end
|
||||||
SetVehicleDoorsLocked(vehicle, 2)
|
SetVehicleDoorsLocked(vehicle, 2)
|
||||||
|
vehicleInfo.occupied = false
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -563,8 +658,8 @@ function CalculateDistanceToCoords(coords)
|
||||||
return #(playerCoords - coords)
|
return #(playerCoords - coords)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Zusätzliche Funktionen für bessere Verwaltung
|
-- Command um nächste Taxi-Station zu finden
|
||||||
function GetNearestTaxiStation()
|
RegisterCommand('nearesttaxi', function()
|
||||||
local playerCoords = GetEntityCoords(PlayerPedId())
|
local playerCoords = GetEntityCoords(PlayerPedId())
|
||||||
local nearestStation = nil
|
local nearestStation = nil
|
||||||
local nearestDistance = math.huge
|
local nearestDistance = math.huge
|
||||||
|
@ -577,21 +672,15 @@ function GetNearestTaxiStation()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return nearestStation
|
if nearestStation then
|
||||||
end
|
|
||||||
|
|
||||||
-- Command um nächste Taxi-Station zu finden
|
|
||||||
RegisterCommand('nearesttaxi', function()
|
|
||||||
local nearest = GetNearestTaxiStation()
|
|
||||||
if nearest then
|
|
||||||
lib.notify({
|
lib.notify({
|
||||||
title = 'Taxi Service',
|
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'
|
type = 'info'
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Waypoint zur nächsten Station setzen
|
-- 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
|
else
|
||||||
lib.notify({
|
lib.notify({
|
||||||
title = 'Taxi Service',
|
title = 'Taxi Service',
|
||||||
|
@ -643,6 +732,9 @@ AddEventHandler('onResourceStop', function(resourceName)
|
||||||
if GetCurrentResourceName() == resourceName then
|
if GetCurrentResourceName() == resourceName then
|
||||||
print("^2[TAXI STATIONS DEBUG]^7 Cleaning up stations...")
|
print("^2[TAXI STATIONS DEBUG]^7 Cleaning up stations...")
|
||||||
|
|
||||||
|
-- TextUI verstecken falls noch angezeigt
|
||||||
|
lib.hideTextUI()
|
||||||
|
|
||||||
-- Alle Station-Fahrzeuge löschen
|
-- Alle Station-Fahrzeuge löschen
|
||||||
for stationId, vehicles in pairs(stationVehicles) do
|
for stationId, vehicles in pairs(stationVehicles) do
|
||||||
for vehicleId, vehicleInfo in pairs(vehicles) do
|
for vehicleId, vehicleInfo in pairs(vehicles) do
|
||||||
|
@ -664,3 +756,4 @@ AddEventHandler('onResourceStop', function(resourceName)
|
||||||
print("^2[TAXI STATIONS DEBUG]^7 Cleanup completed")
|
print("^2[TAXI STATIONS DEBUG]^7 Cleanup completed")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue