Documentation
Search
K
🧬

API

Integrate this awsome inventory with more of your scripts

💎 EXPORTS

Use these exports in server side from other scripts :

Open primary or secondary holder

exports['core_inventory']:openHolder(source, inventoryname, inventorytype, x, y, open, content)

Return :

open the UI with the holder or preload the holder data if open = false

Parameters :

Name
Type
Description
source
number
server id of the player
inventoryname
string
inventory name like 'primary-'.. citizenid / identifier:gsub(':','')
inventorytype
string
inventory type like 'primary' or 'secondry'
x
number
position in pixel on the screen horizontally
y
number
position in pixel on the screen vertically
open
boolean
define if the holder should be open (display) or just preopen (load)
content
table
the default content of the holder (return the content of the holder if it already exist)

Open inventory

exports['core_inventory']:openInventory(source, inventoryname, inventorytype, x, y, open, content)

Return :

Open the UI with the inventory or preload the inventory data if open = false

Parameters :

Name
Type
Description
source
number
server id of the player
inventoryname
string
inventory name like : 'content-'.. citizenid / identifier:gsub(':','') or 'stash-'.. citizenid / identifier:gsub(':','')
inventorytype
string
inventory type like 'content' or 'stash'
x
number
position in pixel on the screen horizontally
y
number
position in pixel on the screen vertically
open
boolean
define if the inventory should be open (display) or just preopen (load)
content
table
the default content of the inventory (return the content of the inventory if it already exist)

Get inventory data

exports['core_inventory']:getInventory(inventory)

Return :

The inventory data in a table

Parameters :

Name
Type
Description
inventory
string
inventory name like : 'content-' .. citizenid / identifier:gsub(':','') or 'stash-' .. citizenid / identifier:gsub(':','') or 'primary-' .. citizenid / identifier:gsub(':','')

Add item

exports['core_inventory']:addItem(inventory, item, amount, metadata, inventoryType)
If you want to add an item in an inventory never open / load, add the inventory type as last parameter, so the inventory will be load and the item will be add in the inventory.

Return :

A table with all the items add with their values

Parameters :

Name
Type
Description
inventory
string
inventory name like : 'content-' .. citizenid / identifier:gsub(':','') or 'stash-' .. citizenid / identifier:gsub(':','') or 'primary-' .. citizenid / identifier:gsub(':','')
item
string
the item name you want to add
amount
number
the amount of item to remove
metadata
table
metadata of the item modify
inventoryType
string
inventory type like 'content' or 'stash'

Remove item

exports['core_inventory']:removeItemExact(inventory, itemId, amount)

Parameters :

Name
Type
Description
inventory
string
inventory name like : 'content-' .. citizenid / identifier:gsub(':','') or 'stash-' .. citizenid / identifier:gsub(':','') or 'primary-' .. citizenid / identifier:gsub(':','')
itemId
string
The item id, not the item name like weapon_pistol-123456
amount
number
the amount of item to remove

Remove item durability

exports['core_inventory']:removeDurability(inventory, itemId, amount)

Parameters :

Name
Type
Description
inventory
string
inventory name where item is located like : 'content-' .. citizenid / identifier:gsub(':','') or 'stash-' .. citizenid / identifier:gsub(':','') or 'primary-' .. citizenid / identifier:gsub(':','')
itemId
string
The item id, not the item name like weapon_pistol-123456
amount
number
The durability to remove from the item. make sure that you the amount is not greater than the remaining durability

Set item durability

exports['core_inventory']:setDurability(inventory, itemId, amount)

Parameters :

Name
Type
Description
inventory
string
inventory name where item is located like : 'content-' .. citizenid / identifier:gsub(':','') or 'stash-' .. citizenid / identifier:gsub(':','') or 'primary-' .. citizenid / identifier:gsub(':','')
itemId
string
The item id, not the item name like weapon_pistol-123456
amount
number
The durability set to the item. Can't be greater than 100

Update item metadata

exports['core_inventory']:updateMetadata(inventory, itemId, metadata)

Parameters :

Name
Type
Description
inventory
string
inventory name where item is located like : 'content-' .. citizenid / identifier:gsub(':','') or 'stash-' .. citizenid / identifier:gsub(':','') or 'primary-' .. citizenid / identifier:gsub(':','')
itemId
number
The item id, not the item name like weapon_pistol-123456
metadata
table
metadata of the item modify

Open a "Loot inventory" with change of getting item in it

Loot inventory is a temporary inventory that can be triggered to reward the player with an item.
exports['core_inventory']:openLoot(source, inventorytype, lootTable, minItems, maxItems)

Return :

open the UI with the generated loot inventory with the item in it

Parameters :

Name
Type
Description
source
number
server id of the player
inventorytype
string
any inventory type you have in your core inventory config file like : 'content' 'stash' 'big_storage' etc.
loottable
table
a table like : { { 'itemName', chanceToBeEarn }, { 'itemName', chanceToBeEarn} } for example : {{"water_bottle", 30},{"weapon_assaultrifle", 5},{"iron", 50}} Here you have 30% chance to have water bottle, 5% chance to have assault rifle, 50% chance to have iron
minItems
number
minimum item add in the inventory if the player have chance to earn it
maxItems
number
maximum item add to the inventory if the player have chance to earn it

Get item in a specific inventory (minimal)

exports['core_inventory']:getItem(inventory, itemName)

Return :

Returns item quantity and general information but only returns one items metadata

Parameters :

Name
Type
Description
inventory
string
inventory name where item is located like : 'content-' .. citizenid / identifier:gsub(':','') or 'stash-' .. citizenid / identifier:gsub(':','') or 'primary-' .. citizenid / identifier:gsub(':','')
itemName
string
name of the item you want to retrieve

Get Item in a specific inventory (full)

exports['core_inventory']:getItems(inventory, item)

Return :

Retuns every item (or stack) with their own specific metadata in a tablehea

Parameters :

Name
Type
Description
inventory
string
inventory name where item is located like : 'content-' .. citizenid / identifier:gsub(':','') or 'stash-' .. citizenid / identifier:gsub(':','') or 'primary-' .. citizenid / identifier:gsub(':','')
itemName
string
name of the item you want to retrieve

🎈GET INVENTORY CLIENT SIDE

Use callback in client side from other scripts
ESX
QB
ESX.TriggerServerCallback('core_inventory:server:getInventory', function(inventory)
for _,v in ipairs(inventory) do
print(v.id)
print(v.name)
print(v.metadata)
end
end)
QBCore.TriggerCallback('core_inventory:server:getInventory', function(inventory)
for _,v in ipairs(inventory) do
print(v.id)
print(v.name)
print(v.metadata)
end
end)

👚 GETTING CLOTHING

To know each value for clothing / props refer to https://wiki.rage.mp/index.php?title=Clothes
For now there are 2 ways of getting clothing to your inventory. The first one is using Core Clothing script. Another is to use a command or export to add item with example metadata shown below.
/giveitem (id) torso 1 {"mTorso":15,"mID":11,"mTexture":1,"mModel":14}

🧬 DYNAMIC ITEMS

Items that are not registered in items.lua or in items table. They can be added with a trigger where you define label, category, x, y, description... in itemData field
TriggerServerEvent('core_inventory:server:addDynamicItem', item, amount, metadata, inventory, itemData)

♾️ OPEN ANY INVENTORY

Opening an inventory is super easy and can be done for anything.
Make sure inventory type exists in config
To open private inventory no one can access with same trigger add identifier/citizenid to inventory name "cupboard-" .. Player.PlayerData.citizenid
TriggerServerEvent('core_inventory:server:openInventory', inventoryname, inventorytype)

Parameters :

Name
Type
Description
inventoryname
string
inventory name like 'police_storage' 'cupboard-' .. citizenid
inventorytype
string
any inventory type you have in your core inventory config file like : 'content' 'stash' 'big_storage' etc.

👥 OPEN PLAYER INVENTORY

Can be added to your radial menu or any other script you use works by default with qb-core
TriggerServerEvent('core_inventory:server:openInventory', playerid, 'otherplayer', nil, nil, withCloth)
Name
Type
Description
playerid
number
server id of the player you want to search
withCloth
boolean
true will open the other player cloth slot if Disable clothing is not set to true in the config