Guide ·
How to Add Items to ox_inventory (with Images and Usable Items)
Add new items to ox_inventory on ESX, QBCore or QBox: the items.lua entry, item images, giving the item in-game and making it usable with an export.
Many scripts need you to add their items to your inventory before they work: a fishing rod, drugs to sell, a gift box. In ox_inventory every item is defined in one file, and adding one takes a few lines.
1. Open items.lua
The file lives at:
resources/[ox]/ox_inventory/data/items.luaIt returns one big table where every key is an item name.
2. Add the item
Add a new entry anywhere inside the table:
['fishing_rod'] = {
label = 'Fishing Rod',
weight = 1500,
stack = false,
close = true,
description = 'A sturdy rod for the lake by Sandy Shores',
},| Field | Meaning |
|---|---|
key (fishing_rod) | The item name scripts use. Lowercase, no spaces. Must match the script's config exactly |
| label | The name players see |
| weight | Weight in grams (1500 = 1.5 kg) |
| stack | false for unique items like tools or weapons |
| close | Close the inventory when the item is used |
| description | Tooltip text |
Watch the commas: a missing , after the closing } breaks the whole file and ox_inventory will not start.
3. Add the item image
Put a PNG named exactly like the item into:
resources/[ox]/ox_inventory/web/images/fishing_rod.pngA square transparent PNG around 100 × 100 px looks right in the grid. Script packs often include their images in an images or inventory_images folder. Copy them all here.
4. Restart the server
ox_inventory loads items when it starts. Restarting only ox_inventory while players are online is not recommended, so do a full server restart.
5. Give yourself the item
In-game or in the server console, as an admin:
/giveitem 1 fishing_rod 1The arguments are player server ID, item name and count. If the command is refused, see how to give yourself admin on FiveM.
Make the item usable
An item does nothing when used until something listens for it. With ox_inventory you can point the item at an export:
['gift_box'] = {
label = 'Gift Box',
weight = 300,
stack = true,
close = true,
server = {
export = 'my_script.useGiftBox',
},
},and in my_script/server.lua:
exports('useGiftBox', function(event, item, inventory, slot, data)
if event == 'usingItem' then
local playerId = inventory.id
exports.ox_inventory:AddItem(playerId, 'money', 500)
return true
end
end)Returning true on usingItem lets ox_inventory remove one from the stack. On ESX, scripts that use ESX.RegisterUsableItem keep working through ox_inventory's bridge, so you only need the export method for your own items.
Client effects: animations and props
For eat/drink style items you can make ox_inventory play an animation and progress bar without any extra script:
['burger'] = {
label = 'Burger',
weight = 220,
client = {
status = { hunger = 200000 },
anim = 'eating',
prop = 'burger',
usetime = 2500,
notification = 'You ate a delicious burger',
},
},Common problems
| Problem | Fix |
|---|---|
| Item shows as "Unknown item" | Name in the script config and items.lua differ, or the server was not restarted |
| Missing image (question mark) | PNG name does not match the item name exactly, or it is not a PNG |
| ox_inventory does not start after editing | Syntax error in items.lua, usually a missing comma. The server console shows the line |
| Using the item does nothing | No export or usable item registered, or the export name has a typo |
Scripts that come with their items ready
SleepyCode Fishing ships ready-made items.lua entries for all 43 of its items plus the matching images, so setup is copy-paste. Browse all FiveM scripts.
Every script for ESX and QBCore, in one place.
Browse scripts