No, you don’t have to.
You want to fix the job, the main problem is vehicle spawning.
Replace function
AddEventHandler('esx_deliveries:startJob:client', function(deliveryType)
with
AddEventHandler('esx_deliveries:startJob:client', function(deliveryType)
local spawned = SpawnDeliveryVehicle(deliveryType)
if spawned then
TriggerEvent("MpGameMessage:send", _U("delivery_start"), _U("delivery_tips"), 3500, 'success')
LoadWorkPlayerSkin(deliveryType)
local ModelHash = GetHashKey("prop_paper_bag_01")
WaitModelLoad(ModelHash)
CreateRoute(deliveryType)
GetNextDeliveryPoint(true)
CurrentType = deliveryType
CurrentStatus = Status.PLAYER_STARTED_DELIVERY
end
end)
And replace
```function SpawnDeliveryVehicle(deliveryType)````
with
function SpawnVehicle(SpawnLocation, deliveryType)
if deliveryType == 'scooter' then
local ModelHash = GetHashKey(Config.Models.scooter)
WaitModelLoad(ModelHash)
-- CurrentVehicle = CreateVehicle(ModelHash, SpawnLocation.x, SpawnLocation.y, SpawnLocation.z, SpawnLocation.h, true, true)
ESX.Game.SpawnVehicle(ModelHash, vector3(SpawnLocation.x, SpawnLocation.y, SpawnLocation.z), SpawnLocation.h, function(spawnedVehicle)
CurrentVehicle = spawnedVehicle
async_Finish_VehicleSpawn(deliveryType)
end)
end
if deliveryType == 'truck' then
local ModelHash = GetHashKey(Config.Models.truck)
WaitModelLoad(ModelHash)
--CurrentVehicle = CreateVehicle(ModelHash, SpawnLocation.x, SpawnLocation.y, SpawnLocation.z, SpawnLocation.h, true, true)
ESX.Game.SpawnVehicle(ModelHash, vector3(SpawnLocation.x, SpawnLocation.y, SpawnLocation.z), SpawnLocation.h, function(spawnedVehicle)
CurrentVehicle = spawnedVehicle
async_Finish_VehicleSpawn(deliveryType)
end)
SetVehicleLivery(CurrentVehicle, 2)
end
if deliveryType == 'van' then
local ModelHash = GetHashKey(Config.Models.van)
WaitModelLoad(ModelHash)
--CurrentVehicle = CreateVehicle(ModelHash, SpawnLocation.x, SpawnLocation.y, SpawnLocation.z, SpawnLocation.h, true, true)
ESX.Game.SpawnVehicle(ModelHash, vector3(SpawnLocation.x, SpawnLocation.y, SpawnLocation.z), SpawnLocation.h, function(spawnedVehicle)
CurrentVehicle = spawnedVehicle
async_Finish_VehicleSpawn(deliveryType)
end)
SetVehicleExtra(CurrentVehicle, 2, false)
SetVehicleLivery(CurrentVehicle, 0)
SetVehicleColours(CurrentVehicle, 0, 0)
end
return CurrentVehicle
end
function SpawnDeliveryVehicle(deliveryType)
local Rnd = GetRandomFromRange(1, #Config.ParkingSpawns)
local SpawnLocation = Config.ParkingSpawns[Rnd]
local max_tries = #Config.ParkingSpawns
while max_tries > -1 do
Rnd = GetRandomFromRange(1, #Config.ParkingSpawns)
SpawnLocation = Config.ParkingSpawns[Rnd]
if ESX.Game.IsSpawnPointClear(vector3(SpawnLocation.x, SpawnLocation.y, SpawnLocation.z), 5.0) then
SpawnVehicle(SpawnLocation, deliveryType)
return true
end
max_tries = max_tries - 1
end
return false
end
function async_Finish_VehicleSpawn(deliveryType)
DecorSetInt(CurrentVehicle, "Delivery.Rental", Config.DecorCode)
SetVehicleOnGroundProperly(CurrentVehicle)
if deliveryType == 'scooter' then
local ModelHash = GetHashKey("prop_med_bag_01")
WaitModelLoad(ModelHash)
local Object = CreateObject(ModelHash, SpawnLocation.x, SpawnLocation.y, SpawnLocation.z, true, false, false)
AttachEntityToEntity(Object, CurrentVehicle, GetEntityBoneIndexByName(CurrentVehicle, "misc_a"), 0.0, -0.55, 0.45, 0.0, 0.0, 0.0, true, true, false, true, 0, true)
table.insert(CurrentVehicleAttachments, Object)
end
if deliveryType == 'van' then
local ModelHash1 = GetHashKey("prop_crate_11e")
local ModelHash2 = GetHashKey("prop_cardbordbox_02a")
WaitModelLoad(ModelHash1)
WaitModelLoad(ModelHash2)
local Object1 = CreateObject(ModelHash1, SpawnLocation.x, SpawnLocation.y, SpawnLocation.z, true, false, false)
local Object2 = CreateObject(ModelHash1, SpawnLocation.x, SpawnLocation.y, SpawnLocation.z, true, false, false)
local Object3 = CreateObject(ModelHash2, SpawnLocation.x, SpawnLocation.y, SpawnLocation.z, true, false, false)
AttachEntityToEntity(Object1, CurrentVehicle, GetEntityBoneIndexByName(CurrentVehicle, "chassic"), 0.25, -1.55, -0.12, 0.0, 0.0, 0.0, true, true, false, true, 0, true)
AttachEntityToEntity(Object2, CurrentVehicle, GetEntityBoneIndexByName(CurrentVehicle, "chassic"), -0.26, -1.55, 0.2, 0.0, 0.0, 0.0, true, true, false, true, 0, true)
AttachEntityToEntity(Object3, CurrentVehicle, GetEntityBoneIndexByName(CurrentVehicle, "chassic"), -0.26, -1.55, -0.12, 0.0, 0.0, 0.0, true, true, false, true, 0, true)
table.insert(CurrentVehicleAttachments, Object1)
table.insert(CurrentVehicleAttachments, Object2)
table.insert(CurrentVehicleAttachments, Object3)
end
end
To fix VAN spawning change config
--van = 's1',
truck = 'mule',
This is enough to fix the job. btw thanks for release, it’s really great.
P.S. You want to finish modification to cancel the fee if vehicle was not able to spawn.