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
- Copy & Paste skills (Itās NOT a joke, while dealing with huge files such as items.lua be careful)
Now carefully follow these instructionsā¦
-
- Open /resources/[qb]/qb-core/shared/items.lua (MAKE BACKUP BEFORE EDITING!)
items.lua: (Example Line of Code)
coffee = { name = 'coffee', label = 'Coffee', weight = 200, type = 'item', image = 'coffee.png', unique = false, useable = true, shouldClose = true, description = 'Buy me a cup of Caffeine.' },
Then,
-
- 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.
-
- Drag & Drop the filename.png into /resources/[qb]/qb-inventory/html/images folder.
FILENAME SHOULD BE IDENTICAL TO THE NAME IN THE CODE!
- Drag & Drop the filename.png into /resources/[qb]/qb-inventory/html/images folder.
-
- Add thirst and hunger values for drinks and food go to /resources/[qb]/qb-smallresources/config.lua MAKE BACKUP BEFORE EDITING!
-
- Go to /resources/[qb]/qb-smallresources/server/consumables.lua and copy and edit this
example code:
QBCore.Functions.CreateUseableItem("coffee", 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)
-
- Rename ācoffeeā to your desired item name If consumable and save changes.
Optional - Add an item to a Shop / Gas Station / Hardware Store etcā¦:
-
- Make sure the item is properly added to the server both in items.lua file & images folder.
-
- Go to /resources/[qb]/qb-shops/config.lua and edit as shown below (example):
(MAKE BACKUP BEFORE EDITING!)
- Go to /resources/[qb]/qb-shops/config.lua and edit as shown below (example):
[69] = { -- Represent the slot of the item in store, replace 69 with whatever you want..
name = "coffee", -- This is Important, use **only** the same name across all scripts...
price = 10, -- The price of the item, is here change it to how much you want.
amount = 420, -- How MANY items are in stock of the store...
info = {}, -- Description of the item
type = "item", -- guess what, It's an item type item... yea.. go figure what jbib is.. :D
slot = 69, -- Use actual number that makes sense, this is just an example
},
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 good luck!
And if I helped you, Iām glad