How to add items to esx_shops

I want to add repair kit, beer, vodka, and coffee. I have added the items in the items table and shops table in the database. However, when I purchase these items, there is no use option. How would I fix this?

2 Likes

You Can start by reading the Doc ? https://github.com/ESX-Org/esx-org.github.io/blob/master/_docs/es_extended/server-functions/esx.registerusableitem.md

EDIT by staff: working link: https://esx-org.github.io/es_extended/server/functions/registerusableitem/

2 Likes

Ok I have added the code in the server/main.lua and added vodka to the database. However I want to add a vodka bottle drinking animation and have a drunk effect on the screen. Do you know anywhere were I can find the animations names or whatever is required in the client/main.lua?

This is what I have so far:

https://pastebin.com/TbVNh8Ck

1 Like

Hey buddy, can you fine the page again? The link seems to be broken!

1 Like

Where do you put the script

1 Like

Did you ever get this resolved

Could you just explain? Your link does not work.

1 Like

link didnt work

2 Likes

Kind people can suggest or give a link to a tutorial how to add more food and drinks to stores?

2 Likes

i think the script ,need be put in esx_extended/server/main.lua
and add the item to the items table database and shops database too
im looking at all the posts of the site for more info about that ,and i can do a full tutorial soon.

1 Like

You have to go to the database and in the “shop” section

Easy steps

First of all go into your database;

Add the items into the ‘items’ section that you want to be available ingame.

go into your shop script. add this item into the config or client lua files. (most shop scripts have bread and water already, so look for these to find out how to add new ones. ***remember, the names must match the names you put into the database)

Then go into your inventory system HTML script and add a new image for the item you added.

then go into your inventory system resource.lua file and add the new item in there too

congratulations, you’ve added an item into your shop.

if you want to use the item

you need to register the item in a script.

in the client lua:

RegisterNetEvent(‘esx_extraitems:firstaidkit’)

AddEventHandler(‘esx_extraitems:firstaidkit’, function()
end)

(change firstaidkid to the item you want to have an effect when used)

server script side:

ESX.RegisterUsableItem(‘firstaidkit’, function(source)

local xPlayer = ESX.GetPlayerFromId(source)

TriggerClientEvent('esx_extraitems:firstaidkit', source)

xPlayer.removeInventoryItem('firstaidkit', 1)

end)

congratulations, your item is now usable. remember that it all has to match with the name you gave it in the database.

At the moment the item based of what we’ve just walked through, wont do anything.
you can add animations, effects by adding lines of code underneath the client lua format i put in for you (above the ‘end’)

6 Likes

I am trying to add some items to the shops the items are already in the database, i have went to the shops and added the items there, restarted my server several times and the items will not show up in the shops not sure what is wrong any help will be appreciatedimage ,

1 Like

also I have seen from other threads about adding the items in the config or client/main.lua where bread and water are, but i do not see where any of the line of code is at for esx_shops

having issue with my item sql it doesnt match up to the markets in city even though i have everything layed out perfect in sql i try to add new market didnt work put old one back in now its fucked when i try to change a item nothing happens the items are stuck on bread and water and i cant even purchase them or change price in item sql doesnt do nothing in game

Have you added the items within the config.lua file?

Did you manage to get it to read from the data base rather than the config.lua?

1 Like

In your esx_shop/config.lua you must have something like this:

Items = {
			{
				name  = 'bread',
				label = _U('bread'),
				price = 35
			},
			{
				name  = 'water',
				label = _U('water'),
				price = 15
			},
			{
				name  = 'fishingrod',
				label = _U('fishingrod'),
				price = 100
			},

The field “name” must be exactly with the name in database. If you use the global _U the first letter is uppercased and the script fails.