[RELEASE][LUA] ESX Deliveries REMAKE

I have a small problem nill value to xPlayer. Maybe someone knows how to fix it?

SCRIPT ERROR: @esx_deliveries/server/main.lua:75: attempt to index a nil value (local 'xPlayer')
AddEventHandler('esx_deliveries:getPlayerJob:server', function()
    local xPlayer = ESX.GetPlayerFromId(source)
	print("Player request job: " .. source .. ", " .. xPlayer.job.name)
	TriggerClientEvent('esx_deliveries:setPlayerJob:client', source, xPlayer.job.name)
end)

Can we get a version that does not need the job center.? I love this script, but i want to move some of the jobs to different locations and also use these types of deliver jobs for police and other jobs to earn side money, thanks a ton I love this!

1 Like

hello i have this error! any solution for this? thanks

same problem

AddEventHandler('esx_deliveries:getPlayerJob:server', function()
    local xPlayer = ESX.GetPlayerFromId(source)
	print("Player request job: " .. source .. ", " .. xPlayer.job.name)
	TriggerClientEvent('esx_deliveries:setPlayerJob:client', source, xPlayer.job.name)
end)

to

AddEventHandler('esx_deliveries:getPlayerJob:server', function()
    local xPlayer = ESX.GetPlayerFromId(source)
        if xPlayer ~= nil then
		print("Player request job: " .. source .. ", " .. xPlayer.job.name)
		TriggerClientEvent('esx_deliveries:setPlayerJob:client', source, xPlayer.job.name)
		end
	end)

I believe this should fix that error…taken from here: [How to Fix] [SOLVED] Attempt to index a nil value (local 'xPlayer') - Server crash

Anyways, why does it have a print there? That will spam your console af.

So i followed every step in the readme file and nothing it coming up on the map or anything, please help

Im getting this issue when using this…

What is that speedometer? :slight_smile:

i can’t get in the scooter e press f and nothing happens.

for me this just hides the problem, if you relog and youre getting the xplayer issue it doesnt seem to load your job. so you wont see the delivery blips, unless you go back to the job centre and re give yourself the job.

you need to reload the job from players every Xms…it seems to load once and not again, I’m not using this so I can’t really tell you exactly.

i need a script where people can put other players in the trunk after carrying them and vise versa

Hello,

I have one error with this script, you can help me ?

SCRIPT ERROR: @esx_deliveries/server/main.lua:64: attempt to call a nil value (field ‘showNotification’)

Just found a little bug with the scooter delivery. The prop_paper_bag_01 doesnt show up. All other props work just the prop_paper_bag_01 doesnt. Can you pls fix this? :slight_smile:

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

Can you make the spawned vehicle full tank

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