forked from Simnation/Main
ed
This commit is contained in:
parent
e3b92cca6f
commit
0f2637b928
3 changed files with 228 additions and 4 deletions
|
@ -330,3 +330,205 @@ AddEventHandler('onResourceStop', function(resourceName)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Event für Admin Respawn
|
||||||
|
RegisterNetEvent('taxi:respawnAllStations', function()
|
||||||
|
-- Alle bestehenden Fahrzeuge löschen
|
||||||
|
for stationId, vehicles in pairs(stationVehicles) do
|
||||||
|
for vehicleId, vehicleInfo in pairs(vehicles) do
|
||||||
|
if DoesEntityExist(vehicleInfo.entity) then
|
||||||
|
exports['qb-target']:RemoveTargetEntity(vehicleInfo.entity)
|
||||||
|
DeleteEntity(vehicleInfo.entity)
|
||||||
|
end
|
||||||
|
if vehicleInfo.driver and DoesEntityExist(vehicleInfo.driver) then
|
||||||
|
DeleteEntity(vehicleInfo.driver)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Stationen neu initialisieren
|
||||||
|
Wait(1000)
|
||||||
|
InitializeTaxiStations()
|
||||||
|
|
||||||
|
lib.notify({
|
||||||
|
title = 'Taxi Service',
|
||||||
|
description = 'Alle Taxi-Stationen wurden neu geladen',
|
||||||
|
type = 'success'
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Zusätzliche Funktionen für bessere Verwaltung
|
||||||
|
function GetNearestTaxiStation()
|
||||||
|
local playerCoords = GetEntityCoords(PlayerPedId())
|
||||||
|
local nearestStation = nil
|
||||||
|
local nearestDistance = math.huge
|
||||||
|
|
||||||
|
for stationId, station in pairs(Config.TaxiStations) do
|
||||||
|
local distance = #(playerCoords - station.blipCoords)
|
||||||
|
if distance < nearestDistance then
|
||||||
|
nearestDistance = distance
|
||||||
|
nearestStation = {id = stationId, data = station, distance = distance}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nearestStation
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Command um nächste Taxi-Station zu finden
|
||||||
|
RegisterCommand('nearesttaxi', function()
|
||||||
|
local nearest = GetNearestTaxiStation()
|
||||||
|
if nearest then
|
||||||
|
lib.notify({
|
||||||
|
title = 'Taxi Service',
|
||||||
|
description = 'Nächste Station: ' .. nearest.data.name .. ' (' .. math.ceil(nearest.distance) .. 'm)',
|
||||||
|
type = 'info'
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Waypoint zur nächsten Station setzen
|
||||||
|
SetNewWaypoint(nearest.data.blipCoords.x, nearest.data.blipCoords.y)
|
||||||
|
else
|
||||||
|
lib.notify({
|
||||||
|
title = 'Taxi Service',
|
||||||
|
description = 'Keine Taxi-Station gefunden',
|
||||||
|
type = 'error'
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Erweiterte Ziel-Optionen für Station-Taxis
|
||||||
|
function OpenStationTaxiMenu(stationId, vehicleId, vehicle, driver, pricePerKm)
|
||||||
|
local options = {}
|
||||||
|
|
||||||
|
-- Bekannte Ziele hinzufügen
|
||||||
|
for _, destination in pairs(Config.KnownDestinations) do
|
||||||
|
local customPrice = math.max(Config.MinFare, math.ceil((CalculateDistanceToCoords(destination.coords) / 1000) * pricePerKm))
|
||||||
|
table.insert(options, {
|
||||||
|
title = destination.name,
|
||||||
|
description = 'Preis: $' .. customPrice .. ' | Entfernung: ' .. math.ceil(CalculateDistanceToCoords(destination.coords) / 1000 * 100) / 100 .. 'km',
|
||||||
|
icon = 'map-marker',
|
||||||
|
onSelect = function()
|
||||||
|
StartStationTaxiRide(stationId, vehicleId, vehicle, driver, destination.coords, customPrice)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Andere Taxi-Stationen als Ziele
|
||||||
|
table.insert(options, {
|
||||||
|
title = '📍 Andere Taxi-Stationen',
|
||||||
|
description = 'Fahre zu einer anderen Taxi-Station',
|
||||||
|
icon = 'taxi',
|
||||||
|
onSelect = function()
|
||||||
|
OpenStationSelectionMenu(stationId, vehicleId, vehicle, driver, pricePerKm)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Waypoint Option
|
||||||
|
table.insert(options, {
|
||||||
|
title = 'Zu meinem Waypoint',
|
||||||
|
description = 'Fahre zu deinem gesetzten Waypoint',
|
||||||
|
icon = 'location-dot',
|
||||||
|
onSelect = function()
|
||||||
|
local waypoint = GetFirstBlipInfoId(8)
|
||||||
|
if DoesBlipExist(waypoint) then
|
||||||
|
local coords = GetBlipInfoIdCoord(waypoint)
|
||||||
|
local distance = CalculateDistanceToCoords(coords) / 1000
|
||||||
|
local price = math.max(Config.MinFare, math.ceil(distance * pricePerKm))
|
||||||
|
StartStationTaxiRide(stationId, vehicleId, vehicle, driver, coords, price)
|
||||||
|
else
|
||||||
|
lib.notify({
|
||||||
|
title = 'Taxi Service',
|
||||||
|
description = 'Du hast keinen Waypoint gesetzt',
|
||||||
|
type = 'error'
|
||||||
|
})
|
||||||
|
OpenStationTaxiMenu(stationId, vehicleId, vehicle, driver, pricePerKm)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Aussteigen Option
|
||||||
|
table.insert(options, {
|
||||||
|
title = 'Aussteigen',
|
||||||
|
description = 'Das Taxi verlassen',
|
||||||
|
icon = 'door-open',
|
||||||
|
onSelect = function()
|
||||||
|
ExitStationTaxi(stationId, vehicleId, vehicle, driver)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
lib.registerContext({
|
||||||
|
id = 'station_taxi_menu',
|
||||||
|
title = 'Taxi - Ziel wählen (' .. Config.TaxiStations[stationId].name .. ')',
|
||||||
|
options = options
|
||||||
|
})
|
||||||
|
|
||||||
|
lib.showContext('station_taxi_menu')
|
||||||
|
end
|
||||||
|
|
||||||
|
function OpenStationSelectionMenu(stationId, vehicleId, vehicle, driver, pricePerKm)
|
||||||
|
local options = {}
|
||||||
|
|
||||||
|
for otherStationId, station in pairs(Config.TaxiStations) do
|
||||||
|
if otherStationId ~= stationId then
|
||||||
|
local distance = CalculateDistanceToCoords(station.blipCoords) / 1000
|
||||||
|
local price = math.max(Config.MinFare, math.ceil(distance * pricePerKm))
|
||||||
|
|
||||||
|
table.insert(options, {
|
||||||
|
title = station.name,
|
||||||
|
description = 'Preis: $' .. price .. ' | Entfernung: ' .. math.ceil(distance * 100) / 100 .. 'km',
|
||||||
|
icon = 'building',
|
||||||
|
onSelect = function()
|
||||||
|
StartStationTaxiRide(stationId, vehicleId, vehicle, driver, station.blipCoords, price)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Zurück Option
|
||||||
|
table.insert(options, {
|
||||||
|
title = '← Zurück',
|
||||||
|
description = 'Zurück zum Hauptmenü',
|
||||||
|
icon = 'arrow-left',
|
||||||
|
onSelect = function()
|
||||||
|
OpenStationTaxiMenu(stationId, vehicleId, vehicle, driver, pricePerKm)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
lib.registerContext({
|
||||||
|
id = 'station_selection_menu',
|
||||||
|
title = 'Taxi-Stationen',
|
||||||
|
options = options
|
||||||
|
})
|
||||||
|
|
||||||
|
lib.showContext('station_selection_menu')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Verbesserte Fahrzeug-Respawn-Logik
|
||||||
|
function RespawnStationVehicle(stationId, vehicleId)
|
||||||
|
if not stationVehicles[stationId] or not stationVehicles[stationId][vehicleId] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local vehicleData = stationVehicles[stationId][vehicleId].data
|
||||||
|
|
||||||
|
-- Prüfen ob Position frei ist
|
||||||
|
local coords = vehicleData.coords
|
||||||
|
local existingVehicles = GetGamePool('CVehicle')
|
||||||
|
local positionBlocked = false
|
||||||
|
|
||||||
|
for _, veh in pairs(existingVehicles) do
|
||||||
|
local vehCoords = GetEntityCoords(veh)
|
||||||
|
if #(vector3(coords.x, coords.y, coords.z) - vehCoords) < 3.0 then
|
||||||
|
positionBlocked = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not positionBlocked then
|
||||||
|
SpawnStationVehicle(stationId, vehicleId, vehicleData)
|
||||||
|
else
|
||||||
|
-- Erneut versuchen nach 30 Sekunden
|
||||||
|
SetTimeout(30000, function()
|
||||||
|
RespawnStationVehicle(stationId, vehicleId)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -94,10 +94,6 @@ Config.TaxiStations = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "Vespucci Beach Taxi",
|
name = "Vespucci Beach Taxi",
|
||||||
coords = vector4(-1266.53, -833.8, 17.11, 37.5),
|
coords = vector4(-1266.53, -833.8, 17.11, 37.5),
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
fx_version 'cerulean'
|
||||||
|
game 'gta5'
|
||||||
|
|
||||||
|
author 'YourName'
|
||||||
|
description 'Taxi System with ox_lib and qb-target'
|
||||||
|
version '1.0.0'
|
||||||
|
|
||||||
|
shared_scripts {
|
||||||
|
'@ox_lib/init.lua',
|
||||||
|
'config.lua'
|
||||||
|
}
|
||||||
|
|
||||||
|
client_scripts {
|
||||||
|
'client/main.lua',
|
||||||
|
'client/stations.lua'
|
||||||
|
}
|
||||||
|
|
||||||
|
server_scripts {
|
||||||
|
'server/main.lua'
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
'qb-core',
|
||||||
|
'ox_lib',
|
||||||
|
'qb-target'
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue