Working with item metadata in ox_inventory
Pass metadata when creating an item — exports.ox_inventory:AddItem(src, 'id_card', 1, { name = 'John Doe' }) — and change it later with SetMetadata(inv, slot, metadata). Built-in keys include durability, serial, registered, ammo, components, label, description, image and weight. Show your own keys in the tooltip with displayMetadata on the client, and fill metadata automatically with a createItem hook.
Metadata is what makes two items with the same name different: this pistol’s serial, that phone’s number, a letter’s text, a bottle half full. In ox_inventory it is a Lua table stored with each item stack, and a few keys have built-in meaning.

#Keys with built-in meaning
| Key | Effect |
|---|---|
durability | 0–100 condition; also used by degrading items and weapons |
serial | Weapon serial number |
registered | Registered owner for weapons (false = no serial) |
ammo | Loaded ammo in a weapon |
components | Attachments on a weapon |
label | Custom display name for this stack |
description | Custom tooltip text |
image | Custom image for this stack |
weight | Extra weight for this stack |
#Adding and changing metadata
-- create with metadata
exports.ox_inventory:AddItem(src, 'id_card', 1, {
label = 'ID — John Doe',
description = 'DOB 1994-03-12',
citizenid = 'ABC12345',
})
-- change an existing stack
local slot = exports.ox_inventory:GetSlotWithItem(src, 'water')
if slot then
local meta = slot.metadata
meta.durability = 50
exports.ox_inventory:SetMetadata(src, slot.slot, meta)
end#Finding items by metadata
-- count ID cards that belong to this citizen
local count = exports.ox_inventory:Search(src, 'count', 'id_card', { citizenid = 'ABC12345' })#Showing custom metadata
exports.ox_inventory:displayMetadata({
citizenid = 'Citizen ID',
plate = 'Plate',
})Now any item with those keys shows them in its tooltip with your labels.
#Setting metadata automatically
exports.ox_inventory:registerHook('createItem', function(payload)
local meta = payload.metadata
meta.issued = os.date('%Y-%m-%d')
return meta
end, { itemFilter = { id_card = true } })A createItem hook may return a table, which becomes the item’s metadata. Weapon serials use the same system — see serial numbers.
Questions
What is metadata in ox_inventory?
How do I give an item a custom name?
label in its metadata when you add it.Why do my items not stack?
How do I show custom metadata in the tooltip?
exports.ox_inventory:displayMetadata({ key = 'Label' }) on the client.Ready to pick a map?
Twelve themes on three base map styles, $8 each, instant download.
Relevant to what you just read
The tool for this
Twenty theme pairs for ox_lib and ox_inventory From $15, built in the browser, exported as a drop-in resource.