[RELEASE][LUA] ESX Deliveries REMAKE

Solved thanks

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.

1 Like

I’m having the same issue. Can you share the solution?

1 Like
-- Spawn the scooter, truck or van

function SpawnDeliveryVehicle(deliveryType)
	
	local Rnd           = GetRandomFromRange(1, #Config.ParkingSpawns)
	local SpawnLocation = Config.ParkingSpawns[Rnd]
	
	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)
		exports["LegacyFuel"]:SetFuel(CurrentVehicle, 100)
	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)
		SetVehicleLivery(CurrentVehicle, 2)
		exports["LegacyFuel"]:SetFuel(CurrentVehicle, 100)
	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)
		SetVehicleExtra(CurrentVehicle, 2, false)
		SetVehicleLivery(CurrentVehicle, 0)
		SetVehicleColours(CurrentVehicle, 0, 0)
		exports["LegacyFuel"]:SetFuel(CurrentVehicle, 100)
	end
	
	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

Main. Lua Replace from line 451
It’s for Legacy Fuel Btw if it’s for ESX Native let me know i can take a look

1 Like

Works perfectly, thank you very much. Do you think it’s possible to require a player to have driver licenses to work there?

1 Like


That’s my issue so far, been trying to fix it and can’t seem to figure out what it is :confused:

Yeah a check can be add.
We keep it that way because it creates an illegal situation for the cops to govern.

Hello everyone. I have some trouble - my van doesn’t open the back doors when I take goods


This is normal?

how do I change women’s clothing? I change in the config and nothing changes, I registered the place of women’s clothing for men and still dresses in women’s clothing

Thank you for this script! i like it… and refuse to work with dll :slight_smile:

Hey, did you manage to find a fix for this issue?

This is an awesome plugin! Welldone m8.

I think i have found a bug though.
my case: Im testing the scooter one, and when i arrive at my destination (on scooter) and the circle says: press e to collect your package i pressed to quick on E to collect, before i was completely off the scooter.
Now the option to grab (press E) is gone, but keeps saying that i have to pick my stuff from the scooter.

Maybe something you can look into.

Thanks

Hi,how can I make it for an activity?I mean I don’t want to use it as a job in the job center,rather I would like to use it as a hobby.Thank you in advance!

How could you make the money go to a society and not to the employee?

ty in advence

Hello how you hide blip so only person who do this job sees it?