Inventory

Client Exports

QBCore, Qbox, ESX, OX

Client Exports

Call these exports from client scripts.

local inventory = exports['tss-inventory']

Client exports operate on the local player and do not take a player server ID.

Available exports

ExportPurpose
HasItem(requirements, amount?)Check the local player's items.
HasItems(requirements, amount?)Check multiple items and amounts.
GetLocalInventory()Get a copy of the personal inventory, or nil before loading.
GetItemDefinitions()Get available item definitions.
OpenSelf()Request the personal inventory and nearby storage.
OpenShop(shopId)Request a configured shop.
CloseInventory()Close the inventory interface.
ItemBox(itemName, action, amount?)Show an item notification without changing inventory contents.

Check items

local hasBandage = inventory:HasItem('bandage', 1)

local hasSupplies = inventory:HasItems({
    bandage = 2,
    water_bottle = 1,
})

You can also supply a list:

local hasBoth = inventory:HasItem({
    'bandage',
    'water_bottle',
}, 1)

Every requested item must have the required amount.

Checks include the cached personal inventory and enabled extra slots. They do not search nested containers.

Client checks are useful for interface behaviour. Use server checks before granting rewards, applying effects or removing items.

Read inventory data

local playerInventory = inventory:GetLocalInventory()

if playerInventory then
    print(playerInventory.id)
end

local definitions = inventory:GetItemDefinitions()

Returned data is a copy. Changing it does not change the real inventory.

Open inventory

inventory:OpenSelf()

This requests the player's inventory and nearby storage, including applicable trunks, gloveboxes and fixed stashes.

Open a shop

inventory:OpenShop('247supermarket_1')

Use a shop ID defined in data/shops.lua or registered by a server script.

Opening exports return true when the request is sent. The server still checks whether access is allowed.

Close inventory

inventory:CloseInventory()

Active crafting must finish or be cancelled first.

Show an item notification

inventory:ItemBox('bandage', 'added', 1)
inventory:ItemBox('bandage', 'removed', 1)
  • Actions are added or removed.
  • Amount defaults to 1.
  • This only displays a notification.
  • It does not add or remove items.
  • Player notification settings still apply.