πŸ“‚Server

getItem

Return all item information group in only one item

Usage :

exports.core_inventory:getItem(inventory, itemName)

Example :

exports.core_inventory:getItem(playerid, 'water')
-- OR
exports.core_inventory:getItem('stash-'.. Player.PlayerData.citizenid, 'water')
-- OR 
exports.core_inventory:getItem('stash-'.. Player.getIdentifier():gsub(':',''), 'water')

Return :

// if water is in the targeted inventory :
{
    "image": "water_bottle.png",
    "label": "Bottle of Water",
    "amount": 1,
    "unique": false,
    "description": "For all the thirsty out there",
    "y": 1,
    "x": 1,
    "name": "water_bottle",
    "metadata": {
        "id": "water_bottle-172736774735962"
    },
    "type": "item",
    "slots": [
        6
    ],
    "info": {
        "id": "water_bottle-172736774735962"
    },
    "count": 1,
    "shouldClose": true,
    "weight": 500,
    "useable": true,
    "ids": [
        "water_bottle-172736774735962"
    ]
}

// if water is not in the targeted inventory :
// QBcore :
nil
// ESX :
Same result as item is in ivnentory but amount / count will be set to 0

// if item or inventory doesn't exist
nil

Parameters :

Name
Type
Description

inventory

string or number

string : the inventory name / number : the player id

itemName

string

name of the item you want to be retrieved


getItems

Return all items stack in a table or item with its specific informations (metadata, amount etc.)

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

string or number

string : the inventory name / number : the player id

itemName

string

name of the item you want to be retrieved


getItemBySlot

Return the item at this slot

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

string or number

string : the inventory name / number : the player id

slot

number

slot you want to retrieve in the inventory


getItemCount

Return count of specify item or items

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

string or number

string : the inventory name / number : the player id

items

string or table

name of the item you want count OR list of items you want to count


getSlotByItem

Return all slot for the item and a total count of items

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

string or number

string : the inventory name / number : the player id

item

string

name of the item you want to retrieve the slot


getFirstSlotByItem

Return the first slot for the item

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

string or number

string : the inventory name / number : the player id

item

string

name of the item you want to be retrieved


getItemsList

Return the list of items from items.lua / item dataabse and also the dynamic items create with registerDynamicItem export

Usage :

Example :


getInventory

Return all inventory items of the inventory

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

string or number

string : the inventory name / number : the player id


addItem

Add Item to a specific inventory

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. However, add will return false since item can't be added in inventory not loaded

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

number or string

string : the inventory name / number : the player id

item

string

the item name you want to add

amount

number

the amount of item to add

metadata

table

metadata of the item on add

inventoryType

string

inventory type like 'content' or 'stash'


removeItem

Remove item in the inventory

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

string

string : the inventory name / number : the player id

item

string

the item name6

amount

number

the amount of item to remove


removeItemExact

Remove item in the inventory by item id

Usage :

Example :

Parameters :

Name
Type
Description

inventory

string

string : the inventory name

itemId

string

The item id, not the item name. Example:weapon_pistol-123456

amount

number

the amount of item to remove


setItem

Set the item in the inventory (add / remove depend of the amount already present in the inventory)

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

number / string

string : the inventory name / number : the player id

item

string

the item name

amount

number

the amount of item to remove

metadata

table

metadata to set to the item too


loadPlayerInventory

Load all the player inventories (Content / holder weapon / cloth hodler if enable) in memory and return the content ivnentory when done

Usage :

Example :


openInventory

Open an inventory on the source screen OR load the inventory if open = false

Usage :

Example :

Parameters :

Name
Type
Description

source

number?

server id of the player, can be nil

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 its already exist)

discoverItem

boolean

if true, the content of the inventory will need to be discovered (item will be hide / shadow)


openHolder

Open an holder like weapon holder (primary / secondry holder) or clothing holder. Can be just load if open = false

Usage :

Example :

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)


canCarry

Return true or false if the inventory can carry the item or not (metadata check)

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

string or number

string : the inventory name / number : the player id

item

string

item you want to check

amount

string

amount of item you want to check

metadata

table

nil if you don't want to check specific metdata


hasItem

Return true or false if the inventory has the item with the amount required

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

string

string : the inventory name / number : the player id

item

string or table

item name or list of item name you wnat to search in inventory

amount

number

the amount of item to search for each items


clearInventory

Clear the inventory content

Usage :

Example :

Parameters :

Name
Type
Description

inventory

string or number

string : the inventory name / number : the player id

source

number?

if player is connected, pass the source to send the clear event if inventory is open, can be nil


clearAllInventory

Clear all the player inventory content (Content / weapon holder / cloth holder)

Usage :

Example :

Parameters :

Name
Type
Description

identifier

string

hte player identifier without ':'

source

number?

if player is connected, pass the source to send the clear event if inventory is open, cna be nil


openLoot

Open a UI inventory with the loot item generated from what it was pass to it. This export will only generate a minimum and a maximum amount of item shared for each item listed in the table. If you want to set minimun and maximum for each item, use openLootAdvanced

Usage :

Example :

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


openLootAdvanced

Open a UI inventory with the loot item generated from what it was pass to it. This export allow you to set a minimum and maximum amount on each item if the chance is reached

Usage :

Example :

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 : { { name = 'itemName', chance = chanceToBeEarn, min = minimumAmount, max = maximumAmount, metadata = { metadatas } }, { name = 'itemName', chance = chanceToBeEarn, min = minimumAmount, max = maximumAmount } } for example : { name = "water_bottle", chance = 30, min = 3, max = 10}, { name = "weapon_assaultrifle", chance = 5, max = 1}} Here you have 30% chance to have water bottle, 5% chance to have assault rifle

addAllSameItem

boolean

instead of adding item by item (if set to false), it will add the full amount of item directly for each item (full stacks of items)

inventory

string

name yo uwnat to give to the inventory if you plan to allow player to reopen loot inventory without regenerate the content

shouldRegenerate

boolean

if true, will regenerate the content of the loot inventory, if false and inventory set, will reopen the loot inventory in the state it have been closed


setDurability

Set the durabiltiy of an item if durability is set on hte metadata item

Usage :

Example :

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


removeDurability

Remove the durability amount on the item.

Usage :

Example :

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


setMetadata

Update the metadata of the item by slot

Usage :

Example :

Parameters :

Name
Type
Description

inventory

number / string

If number : player id else inventory name where item is located like : 'content-' .. citizenid / identifier:gsub(':','') or 'stash-' .. citizenid / identifier:gsub(':','') or 'primary-' .. citizenid / identifier:gsub(':','')

slot

number

slot where the item is located

metadata

table

all metadata of the item modify


updateMetadata

Update the metadata of the item

Usage :

Example :

Parameters :

Name
Type
Description

inventory

number / string

If number : player id else 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


updateInventorySize

Update the size of an inventory (increase / decrease number of slot). If item are in slot you try to removed, the decrease won"t be done.

Usage :

Example :

Return :

Parameters :

Name
Type
Description

inventory

number / string

If number : player id else inventory name where item is located like : 'content-' .. citizenid / identifier:gsub(':','') or 'stash-' .. citizenid / identifier:gsub(':','') or 'inv-small_backpack-123456'

size

number

number of slot you want that hte inventory have at the end


search / searchInventory

Return full / count/ slots / ids of the item in the player inventory

Usage :

Example :

Return :

Parameters:

Name
Type
Description

inventory / source

string or number

Invnetory identifier or player source id

searchtype

string

full / count/ slots/ ids are available.

itemsName

string or table

Item or all items you want information about in player inventory

metadata

table (optional)

Returns only items containing specified metadata


confiscatePlayerInventory

Confiscate all the players inventory (save in another inventory). Use returnPlayerInventory to send back all the inventory.

Usage :

Return :

Parameters :

Name
Type
Description

source

number

server id of the player, need to be online


confiscateInventory

Confiscate the inventory pass as parameter. Use returnInventory to send back the inventory.

Usage :

Example :

Return :

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(':','')

source

number?

server id of the player. can be nil not required

inventoryType

string

inventory type like 'primary' or 'secondry'


returnPlayerInventory

Return all inventory of the player that have been confiscated before with confiscatePlayerInventory

Usage :

Return :

Parameters :

Name
Type
Description

source

number

server id of the player, need to be online


returnInventory

Return all item of the confiscated inventory with confiscateInventory

Usage :

Example :

Return :

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(':','')

inventoryType

string

inventory type like 'primary' or 'secondry'


registerDynamicItem

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 etc.

Usage :

Example :

Parameters :

Name
Type
Description

itemName

string

name of the item

itemData

table

item data that will be use to setup the item ( all qbcore shared item data or item database ciolumn can be used). If no category is add to the item, 'misc' is used by default

force

boolean

force the item creation even if it already exist

Last updated