Inventories
How the wheel reads your inventory, and how to plug your own.
The wheel never touches the items itself: it reads the inventory of the player and asks the inventory to use the item, exactly like a hotbar would. Every rule of your inventory (durability, item callbacks, weapon animations) still applies.
| Inventory | Items | Use | Images |
|---|---|---|---|
| ox_inventory | GetPlayerItems | useSlot | nui://ox_inventory/web/images/ |
| qb-inventory 2.x | Player data | qb-inventory:server:useItem | nui://qb-inventory/html/images/ |
| qb / ps / lj-inventory 1.x | Player data | inventory:server:UseItemSlot | nui://<resource>/html/images/ |
| qs-inventory | getUserInventory | inventory:server:UseItemSlot | nui://qs-inventory/html/images/ |
| ESX default | inventory + loadout | esx:useItem / weapon in hand | none, set Config.Images.path |
Weapons or items#
An item goes on the weapons wheel when the inventory marks it as a weapon, or when its name starts with WEAPON_. Everything else goes on the items wheel.
Ammo#
For a weapon in hand, the ammo in the clip and the ammo left come from the game. Otherwise the wheel shows the ammo saved by the inventory (metadata.ammo on ox_inventory, info.ammo on qb-inventory). On ox_inventory the reserve is the amount of the ammo item of the weapon.
Custom inventory#
Set Config.Inventory = 'custom' and fill client/inventory/custom.lua:
Inventory.ImagePath = 'nui://my_inventory/html/images/'
function Inventory.GetItems()
local items = {}
for _, item in pairs(exports.my_inventory:GetItems()) do
items[#items + 1] = {
name = item.name,
label = item.label,
count = item.amount,
slot = item.slot,
weapon = item.type == 'weapon',
ammo = item.info and item.info.ammo,
image = item.image,
}
end
return items
end
function Inventory.UseItem(item)
TriggerServerEvent('my_inventory:useSlot', item.slot)
end
function Inventory.Disarm()
SetCurrentPedWeapon(cache.ped, `WEAPON_UNARMED`, true)
endInventoryItem:
name:string- also used to save the wheellabel?:stringcount:number- items at0are ignoredslot?:number- given back toInventory.UseItemweapon?:booleanammo?:number- ammo loaded in the weaponreserve?:number- ammo left in the inventoryimage?:string- file name (pistol.png) or full url (https://,nui://)description?:string
Tell the wheel when the inventory changes so it removes the items the player lost:
TriggerEvent('cube_itemswheel:inventoryChanged')The wheel also refreshes when it opens and after each use, so this event is optional - it only makes the cleanup instant.