[Release][ESX][Standalone] Order preparation / Delivery Job

unknown
Hi everyone !

It is a simple delivery / order preparation job. You just have to move an object with a forklift from point A to point B.

Download the script from the repo on github.

You may watch the video preview here:

Everything you can easily modify:

Change salary
You can simply modify the salary. Salary is a randomized value between Config.MinSalaire and Config.MaxSalaire. You can simply modify those 2 variables to increase or decrease the salary.

Config.MaxSalaire = 25
Config.MinSalaire = 19

Alternatively, you can set a fixed value by commenting line 36 and uncommenting line 37 in client.lua.

local salaire = math.random(Config.MinSalaire, Config.MaxSalaire)
--local salaire = Config.MaxSalaire

ESX and compatibility with other frameworks
Since ESX is only used to add money to the player once the job is done, you can easily make the script compatible with any framework you want.

Add more delivries/locations
You just have to modify the config file called config.lua.
You can add more props and more locations by modifying Config.props.
You can also add more delivry locations by modifying Config.pos.

En français?
Non, je ne vais pas traduire tout ce que j’ai dit au-dessus… Chaque notification est traduite en français dans client.lua et server.lua. Il suffit de uncomment la ligne en français et commenter la ligne en anglais.
Exemple ligne 44:

--drawnotifcolor("Livraison effectuée", 25)
drawnotifcolor("Delivery is done", 25)
17 Likes

Awesome. Thanks for the work!

1 Like

love you work man thanks <3

1 Like

Good Job. :smiley:

2 Likes

Very good resource <3
Thanks for making it’s for free.
Greeting from germany

1 Like

Thank you!!! :smiley:

1 Like

@floWonFiveM

Good morning, if I want to get something when I finish my work…not just money, how do I need to modify it?

1 Like

Hi, if you’re on ESX, you just have to follow the documentation.
According to the doc, you would have to do this modification:

RegisterServerEvent("portjob:getMoney")
AddEventHandler("portjob:getMoney", function(salaire)
    local xPlayer = ESX.GetPlayerFromId(source)
    local i = 0

    for k,v in pairs (salaire) do 
        if v > Config.MaxSalaire then 
            print (xPlayer.identifier.." is a cheater")
            return
        end
        xPlayer.addAccountMoney('bank', v)
        i = i + v
    end
    --xPlayer.showNotification("Tu as reçu ~g~"..i.."$", i)
    xPlayer.showNotification("You've received ~g~$"..i, i)
	if xPlayer.canCarryItem(itemName, itemCount) then
		xPlayer.addInventoryItem(itemName, itemCount)
	else
		xPlayer.showNotification('Target player could not hold all of that.')
	end
end)

This would add the item you want to add after finishing the job. You just have to modify ItemCount and ItemName.
You can access the number of deliveries done, with #salaire. So, for example, if you want to give bread to the player and want the player to have as much bread as delivries done, you can do that:

RegisterServerEvent("portjob:getMoney")
AddEventHandler("portjob:getMoney", function(salaire)
    local xPlayer = ESX.GetPlayerFromId(source)
    local i = 0

    for k,v in pairs (salaire) do 
        if v > Config.MaxSalaire then 
            print (xPlayer.identifier.." is a cheater")
            return
        end
        xPlayer.addAccountMoney('bank', v)
        i = i + v
    end
    --xPlayer.showNotification("Tu as reçu ~g~"..i.."$", i)
    xPlayer.showNotification("You've received ~g~$"..i, i)
	if xPlayer.canCarryItem("bread", #salaire) then
		xPlayer.addInventoryItem("bread", #salaire)
	else
		xPlayer.showNotification('Target player could not hold all of that.')
	end
end)

or

RegisterServerEvent("portjob:getMoney")
AddEventHandler("portjob:getMoney", function(salaire)
    local xPlayer = ESX.GetPlayerFromId(source)
    local i = 0

    for k,v in pairs (salaire) do 
        if v > Config.MaxSalaire then 
            print (xPlayer.identifier.." is a cheater")
            return
        end
        xPlayer.addAccountMoney('bank', v)
        i = i + v
		
		if xPlayer.canCarryItem("bread", 1) then
			xPlayer.addInventoryItem("bread", 1)
		else
			xPlayer.showNotification('Target player could not hold all of that.')
		end
    end
    --xPlayer.showNotification("Tu as reçu ~g~"..i.."$", i)
    xPlayer.showNotification("You've received ~g~$"..i, i)

end)

I have not tested but the first and second example should work. You could also easily add arguments to the server event that would specify the ItemName or ItemCount.

If you need more help, don’t hesitate to ask!

Every time I add a if Playerdata.job… the script doesn’t work anymore…


this is my code

ESX isn’t used in client.lua.
To fix your issue, try adding the following code in the first lines of client.lua:

ESX                             = nil

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end

	while ESX.GetPlayerData().job == nil do
		Citizen.Wait(10)
	end

	ESX.PlayerData = ESX.GetPlayerData()
end)

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
	ESX.PlayerData = xPlayer
end)

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
	ESX.PlayerData.job = job
end)

Oh my goodness…you took me into a new world…thank you so much…

But if the item I need to obtain is random, how do I need to modify it?

thanks a lot, also I have a problem when I edit the key to attach the object to the forklift…
After edit the key I can attach the object but I don’t get a marker to deliver it.

Try to find errors in your client console.

local Items ={
    "bread",
    "water",
    "phone",
}

function math.randomchoice(d) --Selects a random item from a table
    local keys = {}
    for key, value in pairs(d) do
        keys[#keys+1] = key --Store keys in another table
    end
    index = keys[math.random(1, #keys)]
    return d[index]
end

RegisterServerEvent("portjob:getMoney")
AddEventHandler("portjob:getMoney", function(salaire)
    local xPlayer = ESX.GetPlayerFromId(source)
    local i = 0
    local item

    for k,v in pairs (salaire) do 
        item = math.randomchoice(Items)
        if v > Config.MaxSalaire then 
            print (xPlayer.identifier.." is a cheater")
            return
        end
        xPlayer.addAccountMoney('bank', v)
        i = i + v
		
		if xPlayer.canCarryItem(item, 1) then
			xPlayer.addInventoryItem(item, 1)
		else
			xPlayer.showNotification('Target player could not hold all of that.')
		end
    end
    --xPlayer.showNotification("Tu as reçu ~g~"..i.."$", i)
    xPlayer.showNotification("You've received ~g~$"..i, i)

end)

Haven’t tested but this should work. It’s the same method used in client.lua. You add any item you want in the table called Items

Awesome!

1 Like

thanks, i translated it in vrp and it works perfectly <3

1 Like

Hey! I converted your script to use the ND_Framework by Andy7666 money system, which is a little framework I use on my server.
I am currently in the process of converting many others standalone job script to this framework, since it’s very new and not that popular yet, and then release like a “pack” with all of these modified scripts.
Therefore I would really like to re-release this with the modifications I’ve done, while of course crediting you. Am I allowed?
Thanks.

Sure, do whatever you want with the script except selling it.

Hi ! You can change the props in the config file. In this file, you can find a table variable called Config.props. In each element of this table, you can modify the attribute called model. This attribute is the model id. Every model id can be find at the following link : https://gta-objects.xyz/

Thx that worked im trying to convert it to a dock handler but i dont know enough about scripting.

Already have the dock handler and the containers in it while using 2scripts :S but the drop of point doesnt do what i want :frowning: