mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
refactor(esx_taxijob): Make it work + Serverside spawning
This commit is contained in:
@@ -173,13 +173,9 @@ function OpenVehicleSpawnerMenu()
|
||||
menu.close()
|
||||
|
||||
local vehicleProps = data.current.value
|
||||
ESX.Game.SpawnVehicle(vehicleProps.model, Config.Zones.VehicleSpawnPoint.Pos,
|
||||
Config.Zones.VehicleSpawnPoint.Heading, function(vehicle)
|
||||
ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
|
||||
local playerPed = PlayerPedId()
|
||||
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
|
||||
end)
|
||||
|
||||
ESX.TriggerServerCallback("esx_taxijob:SpawnVehicle", function()
|
||||
return
|
||||
end, vehicleProps.model, vehicleProps)
|
||||
TriggerServerEvent('esx_society:removeVehicleFromGarage', 'taxi', vehicleProps)
|
||||
end, function(data, menu)
|
||||
CurrentAction = 'vehicle_spawner'
|
||||
@@ -203,11 +199,9 @@ function OpenVehicleSpawnerMenu()
|
||||
end
|
||||
|
||||
menu.close()
|
||||
ESX.Game.SpawnVehicle(data.current.model, Config.Zones.VehicleSpawnPoint.Pos,
|
||||
Config.Zones.VehicleSpawnPoint.Heading, function(vehicle)
|
||||
local playerPed = PlayerPedId()
|
||||
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
|
||||
end)
|
||||
ESX.TriggerServerCallback("esx_taxijob:SpawnVehicle", function()
|
||||
ESX.ShowNotification(_U('vehicle_spawned'), "success")
|
||||
end, data.current.model, {plate = "TAXI JOB"})
|
||||
end, function(data, menu)
|
||||
CurrentAction = 'vehicle_spawner'
|
||||
CurrentActionMsg = _U('spawner_prompt')
|
||||
|
||||
@@ -7,6 +7,7 @@ Locales['en'] = {
|
||||
|
||||
-- garage
|
||||
['spawner_prompt'] = 'press [E] to access the Garage.',
|
||||
["vehicle_spawned"] = "Successfully Spawned A ~b~Taxi!",
|
||||
['store_veh'] = 'press [E] to store the vehicle',
|
||||
['spawn_veh'] = 'spawn vehicle',
|
||||
['spawnpoint_blocked'] = 'there is a vehicle blocking the spawnpoint!',
|
||||
|
||||
@@ -45,6 +45,22 @@ AddEventHandler('esx_taxijob:success', function()
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback("esx_taxijob:SpawnVehicle", function(source, cb, model , props)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
if xPlayer.job.name ~= "taxi" then
|
||||
print(('[esx_taxijob] [^3WARNING^7] ^5%s^7 attempted to spawn a vehicle (not taxi job)'):format(xPlayer.identifier))
|
||||
return
|
||||
end
|
||||
local SpawnPoint = vector3(Config.Zones.VehicleSpawnPoint.Pos.x, Config.Zones.VehicleSpawnPoint.Pos.y, Config.Zones.VehicleSpawnPoint.Pos.z)
|
||||
ESX.OneSync.SpawnVehicle(joaat(model), SpawnPoint, Config.Zones.VehicleSpawnPoint.Heading, true, props, function(vehicle)
|
||||
local vehicle = NetworkGetEntityFromNetworkId(vehicle)
|
||||
print("Vehicle Spawned")
|
||||
TaskWarpPedIntoVehicle(GetPlayerPed(source), vehicle, -1)
|
||||
end)
|
||||
cb()
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_taxijob:getStockItem')
|
||||
AddEventHandler('esx_taxijob:getStockItem', function(itemName, count)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
Reference in New Issue
Block a user