diff --git a/[esx_addons]/esx_taxijob/client/main.lua b/[esx_addons]/esx_taxijob/client/main.lua index f88b42c9..3b16976c 100644 --- a/[esx_addons]/esx_taxijob/client/main.lua +++ b/[esx_addons]/esx_taxijob/client/main.lua @@ -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') diff --git a/[esx_addons]/esx_taxijob/locales/en.lua b/[esx_addons]/esx_taxijob/locales/en.lua index 98ad22a6..9721f5e3 100644 --- a/[esx_addons]/esx_taxijob/locales/en.lua +++ b/[esx_addons]/esx_taxijob/locales/en.lua @@ -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!', diff --git a/[esx_addons]/esx_taxijob/server/main.lua b/[esx_addons]/esx_taxijob/server/main.lua index 091aa9af..6ac7c9e4 100644 --- a/[esx_addons]/esx_taxijob/server/main.lua +++ b/[esx_addons]/esx_taxijob/server/main.lua @@ -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)