[Release][ESX] Crafting System

Please, post it!

Thanks.

Hello, I have some problem, if I click to craft item nothing doing and i can´t close menu.Thanks for help

how we can change the script that only the mafia can see the crafting point or only mafia permission?

must be named esx_crafting or it won’t work

Look where it defines the blip and remove it. Or build in a way to show it only to one job

thanks

Not a problem mate !

it´s not working

Please can you share mate

I will grab the code when i get home today and post it

3 Likes

Alrighty ladies and gents. as mentioned i did find a way to modify the script to allow more than 1 qty output of a given recipe. it’s done with very little changes to the script and shouldn’t cause any issues as long as you know what you are doing.

I AM NOT RESPONSIBLE FOR ANY ISSUES

Now, the reason you are here :slight_smile:

modify your "config.lua"

Change your Item name from this…

["lockpick"] = {...

to this

["lockpick,4]

The “4” is where you would put the qty of how many you want to give the person.

modify your "server.lua"

Find the following line (roughly line 60)

AddEventHandler('salty_crafting:craftItem', function(ingredients)

and replace the function with this (roughly line 60 - 88)

AddEventHandler('salty_crafting:craftItem', function(ingredients)
	local _source = source
	local xPlayer = ESX.GetPlayerFromId(_source)
	local item = findRecipe(ingredients)

	if not item then
		TriggerClientEvent('esx:showNotification', _source, 'No recipe found with these ingredients')
	else
		if xPlayer ~= nil then
			if hasAllIngredients(xPlayer.inventory, Config.Recipes[item]) then
				for _,ingredient in pairs(Config.Recipes[item]) do
					if (ingredient.remove ~= nil and ingredient.remove) or (ingredient.remove == nil) then
						xPlayer.removeInventoryItem(ingredient.item, ingredient.quantity)
					end
				end
				if string.match(string.lower(item), "weapon_") then
					xPlayer.addWeapon(item, Config.WeaponAmmo)
				else
					string = item
					item, qty = string:match("([^,]+),([^,]+)")
					xPlayer.addInventoryItem(item, qty)
				end
				TriggerClientEvent('esx:showNotification', _source, '~y~Item Crafted: ~w~' .. itemLabel(item, xPlayer.inventory))
			else
				TriggerClientEvent('esx:showNotification', _source, 'You do not have all of the ingredients')
			end
		end
	end
end)

I can try solving any issues related, but there shouldn’t be any :slight_smile:

6 Likes

it works. THANKYOU

here is a idea not sure if possible but what are the chances of making a item work kinda like the crafting bench example could be like a Drug scale (once you have the item on you, you can then using the correct recipe maybe bag drugs,break down larger amounts to small amounts, so on so forth?

For everyone who has the “can open but can’t close the menu” error (NUI callbacks) and want to rename the folder, here’s the solution:

You want to rename the folder, for example, in salty_crafting123 you have to edit the HTML file.

  • Go in salty_crafting/html
  • Open index.html
  • You have to replace every salty_crafting you find in the HTML into salty_crafting123.

Done. It worked for me.

I can open the UI via the pressing E, but i cant open the Shop?

Hello, I would like these buttons to be automatic, that is, if you leave the “+” button pressed and it is added, for example. the value is “0”, when you press the “+”, that 0 will automatically increase. I do not know if they understand me :confused:
https://gyazo.com/b5a82fb41b43422d25735e53b7f0b172

is there any way to make it so it displays all the craftable items and whats needed to craft them?

2 Likes

Any idea why when crafting WEAPON_PISTOL it crafts an item called pistol but said item is not even a weapon…?

Like i buy a pistol from ammunation, and i craft a pistol… no ammo, not an equitpable item

i do ti, but doesn’t work for me, when i press craft, nothing appens