[Tutorial] QBCore - How to add items correctly

Hey there,
Yorzen here with a quick & easy tutorial for adding items into your server. [QBCore framework]

Things you will need:
100x100px .png file of your desired item.
Access to the FTP Server. (can be used locally)
Patience and a functioning brain :wink:
Copy & Paste skills (Itā€™s NOT a joke, while dealing with huge files such as items.lua be careful)

  1. Open /resources/[qb]/qb-core/shared/items.lua (MAKE BACKUP BEFORE EDITING!)
  2. Add the correct line of code of a similar item (copy & paste similar line of code) edit the item details such as weight, description and so onā€¦ then save changes.
  3. Drag & Drop the filename.png into /resources/[qb]/qb-inventory/html/images folder.
    FILENAME SHOULD BE IDENTICAL TO THE NAME IN THE CODE!
  4. Add thirst and hunger values for drinks and food go to /resources/[qb]/qb-smallresources/config.lua MAKE BACKUP BEFORE EDITING!
  5. Go to /resources/[qb]/qb-smallresources/server/consumables.lua and copy and edit this example code:
QBCore.Functions.CreateUseableItem("sandwich", function(source, item)
    local Player = QBCore.Functions.GetPlayer(source)
	if Player.Functions.RemoveItem(item.name, 1, item.slot) then
        TriggerClientEvent("consumables:client:Eat", source, item.name)
    end
end)
  1. Rename ā€œsandwichā€ to your desired item name If consumable and save changes.

Optional - Add an item to shop / gas station / hardwarestore etcā€¦:

  1. Make sure the item is properly added to the server both in items.lua file & images folder.
  2. Go to /resources/[qb]/qb-shops/config.lua and edit as shown below (example):
    (MAKE BACKUP BEFORE EDITING!)
        [14] = {
            name = "clipper420",
            price = 10,
            amount = 420,
            info = {},
            type = "item",
            slot = 14,
        },

Important notes: The Item Number [ ] in config.lua must be incremented by +1 *Last item on the list copy and paste and change both [x] and slot = x increase by +1 (Example: [14] turns to [15])
Important: .png file resolution must be 100 x 100px
Important: Edit values of Weight, Price, Description etcā€¦

Verify and save all config files and restart the server to see the changes.

If youā€™re still struggling let me know down in the comments Iā€™ll do my best to simplify it a little more.

P.S Iā€™ve tried to look for a tutorial and didnā€™t find any of this topic thought it could help some of you out there :slight_smile:

Visit our server Harmony RP|18+|Discord|Global / Cfx.re (click to join)
Discord: š“—š“Ŗš“»š“¶š“øš“·š”‚ š“”š“Ÿ | 18+šŸŒŽ
Peace,
Yorzen

18 Likes

Nice tuto, it will become handy for beginner developers on qbcore.

4 Likes

Thank you sir :slight_smile:

How would i add a table to my database for my items

1 Like

Thanks, really helpful!

1 Like

Has there been an update at some point within the framework coding since you posted this?

Context: I had a server previously, running an older version of Qbus and everything worked perfectly after following these steps given by yourself <3

I have since updated Qbus to itā€™s latest framework, and now additional items I have added donā€™t seem to work.

I have added all the images to qb-inventory/html/images
Images added

I have added all the items to qb-core/shared/items.lua
Items added to qb-core

However, the problem I find, is when I add the items to qb-smallresources/config.lua (like I did before)
Seen here
The game then decides that I canā€™t use the items

Soā€¦ I checked out the qb-smallresources/server/consumables.lua and noticed a change in the way the script is presented to how I did it previously.
Consumables differences shown here

I tested out using a copy of the consumables.lua from my old server into my new server and then the characters were able to consume a product, emote eating a burger or drinking a bottle, but it would not replenish any hunger or thirst. It also started flagging up that ā€˜progressbarā€™ couldnā€™t detect the events required.

So now I have reverted back to the default qb-smallresources and will have to wait on some eye opening answer for my problem until I attempt it again.

hello, I have some issues.

I created blackmoney as item, and when I tried the item (doing a robbery) my inventory just shows 100 (not the real amount that i robbed)

I edited the max amount on qb-inventory but itā€™s always showing just 100.

I donā€™t know if its an error of the item created or what, but with the cash its working perfectly.

New Format is Made On latest Nowadays looking like this aswell gonna throw up a tutorial for all thats been changed in the lastest ones later on aswell :smiley:

Config.Products = {
[ā€˜normalā€™] = {
{name = ā€˜tostiā€™, price = 20, amount = 100, info = {}, type = ā€˜itemā€™},
{name = ā€˜water_bottleā€™, price = 20, amount = 100, info = {}, type = ā€˜itemā€™},
{name = ā€˜kurkakolaā€™, price = 20, amount = 100, info = {}, type = ā€˜itemā€™},
{name = ā€˜twerks_candyā€™, price = 20, amount = 100, info = {}, type = ā€˜itemā€™},
{name = ā€˜snikkel_candyā€™, price = 20, amount = 100, info = {}, type = ā€˜itemā€™},
{name = ā€˜sandwichā€™, price = 20, amount = 100, info = {}, type = ā€˜itemā€™},
},

1 Like

Thanks for letting me know, I will update it to the new version of QB-Core Items.lua

1 Like