📂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 :

NameTypeDescription

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 :

exports.core_inventory:getItems(inventory, itemName)

Example :

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

Return :

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

// if water is not in the targeted inventory :
[]

Parameters :

NameTypeDescription

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 :

exports.core_inventory:getItemBySlot(inventory, slot)

Example :

exports.core_inventory:getItemBySlot(playerid, 0)
-- OR
exports.core_inventory:getItemBySlot('stash-'.. Player.PlayerData.citizenid, 5)
-- OR 
exports.core_inventory:getItemBySlot('stash-'.. Player.getIdentifier():gsub(':',''), 3)

Return :

// if there is an item in slot 0:
{
    "type": "item",
    "unique": false,
    "weight": 500,
    "slot": 0,
    "info": [],
    "id": "water_bottle-172736828738747",
    "count": 2,
    "shouldClose": true,
    "metadata": [],
    "description": "For all the thirsty out there",
    "image": "water_bottle.png",
    "label": "Bottle of Water",
    "amount": 2,
    "useable": true,
    "name": "water_bottle"
}
// if there is not an item in slot 0:
nil

Parameters :

NameTypeDescription

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 :

local count = exports.core_inventory:getItemCount(inventory, items)

Example :

exports.core_inventory:getItemCount(playerid, 'water')
-- OR
exports.core_inventory:getItemCount('stash-'.. Player.PlayerData.citizenid, { 'water', 'juice' })
-- OR 
exports.core_inventory:getItemCount('stash-'.. Player.getIdentifier():gsub(':',''), 'juice')

Return :

// if water is in the targeted inventory (amount = 2):
2
// if water is not in the targeted inventory :
0

Parameters :

NameTypeDescription

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 :

local slots, totalCount = exports.core_inventory:getSlotsByItem(inventory, item)

Example :

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

Return :

// if water is in the targeted inventory at slot 7 and 33:
[ 7, 33 ]
// if water is not in the targeted inventory :
[]

Parameters :

NameTypeDescription

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 :

exports.core_inventory:getFirstSlotByItem(inventory, item)

Example :

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

Return :

// if water is in the targeted inventory in slot 7 and 33 :
7
// if water is not in the targeted inventory :
nil

Parameters :

NameTypeDescription

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 :

local items = exports.core_inventory:getItemsList()

Example :

local items = exports.core_inventory:getItemsList()

getInventory

Return all inventory items of the inventory

Usage :

exports.core_inventory:getInventory(inventory)

Example :

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

Return :

// Example with items in inventory :
[
    {
        "ammotype": "AMMO_RIFLE",
        "metadata": {
            "ammo": 0,
            "serial": "AE701417",
            "attachments": [],
            "aquired": "content-KXD43680",
            "durability": 100
        },
        "count": 1,
        "amount": 1,
        "image": "weapon_assaultrifle_mk2.png",
        "info": {
            "ammo": 0,
            "serial": "AE701417",
            "attachments": [],
            "aquired": "content-KXD43680",
            "durability": 100
        },
        "category": "weapons",
        "label": "Assault Rifle Mk II",
        "useable": true,
        "unique": true,
        "slot": 1,
        "weight": 1000,
        "description": "Assault Rifle MK2",
        "type": "weapon",
        "name": "weapon_assaultrifle_mk2",
        "id": "weapon_assaultrifle_mk2-172719708021772"
    },
    {
        "id": "water_bottle-17273686944580",
        "shouldClose": true,
        "info": [],
        "unique": false,
        "image": "water_bottle.png",
        "count": 2,
        "weight": 500,
        "label": "Bottle of Water",
        "ids": [
            "water_bottle-17273686944580"
        ],
        "slots": [
            0
        ],
        "amount": 2,
        "metadata": [],
        "description": "For all the thirsty out there",
        "type": "item",
        "name": "water_bottle",
        "useable": true
    }
]

Parameters :

NameTypeDescription

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 :

local itemsAdd = exports.core_inventory:addItem(inventory, item, amount, metadata, inventoryType)

Example :

exports.core_inventory:addItem(playerid, 'water', 1)
-- OR
exports.core_inventory:addItem('stash-'.. Player.PlayerData.citizenid, 'water', 1 , { uses = 5 }, 'stash')
-- OR 
exports.core_inventory:addItem('stash-'.. Player.getIdentifier():gsub(':',''), 'water', 5 , { uses = 10, time = os.time() }, 'stash')

Return :

// Empty table if only stack are increase 
// OR all created new stack on inventory
// OR false if it can't be added 
// (inventory not load and type not define / no space in inventory)

Parameters :

NameTypeDescription

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 :

local removed = exports.core_inventory:removeItem(inventory, item, amount, inventoryType)

Example :

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

Return :

true or false if item is removed or not

Parameters :

NameTypeDescription

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 :

exports.core_inventory:removeItemExact(inventory, itemId, amount)

Example :

exports.core_inventory:removeItemExact(playerid, 'water-23453', 1)
-- OR
exports.core_inventory:removeItemExact('stash-'.. Player.PlayerData.citizenid, 'water-45938', 1)
-- OR 
exports.core_inventory:removeItemExact('stash-'.. Player.getIdentifier():gsub(':',''), 'water-23093', 1)

Parameters :

NameTypeDescription

inventory

string

string : the inventory name / number : the player id

itemId

string

The item id, not the item name like 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 :

local removed = exports.core_inventory:setItem(inventory, item, amount, metadata)

Example :

exports.core_inventory:setItem(playerid, 'water', 1)
-- OR
exports.core_inventory:setItem('stash-'.. Player.PlayerData.citizenid, 'water', 1, { use = 5 })
-- OR 
exports.core_inventory:setItem('stash-'.. Player.getIdentifier():gsub(':',''), 'water', 1

Return :

true or false if item is set or not

Parameters :

NameTypeDescription

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 :

exports.core_inventory:loadPlayerInventory(identifier)

Example :

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

openInventory

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

Usage :

exports.core_inventory:openInventory(source, inventory, inventoryType, x, y, open, content, discoverItem)

Example :

-- Open inventory on player screen :
exports.core_inventory:openInventory(playerid, 'stash-'.. Player.PlayerData.citizenid, 'stash', nil, nil, true, nil, false)
-- OR
exports.core_inventory:openInventory(playerid, 'stash-'.. Player.getIdentifier():gsub(':','', 'stash', nil, nil, true, nil, false)

-- Load the inventory content for futur use (it's like RegisterStash)
exports.core_inventory:openInventory(nil, 'stash-police-storage', 'stash', nil, nil, false, nil, false)

Parameters :

NameTypeDescription

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 :

exports.core_inventory:openHolder(source, inventory, inventoryType, x, y, open, content, discoverItem)

Example :

-- Open inventory on player screen :
exports.core_inventory:openHolder(playerid, 'primary-'.. Player.PlayerData.citizenid, 'primary', nil, nil, true, nil)
-- OR
exports.core_inventory:openHolder(playerid, 'primary-'.. Player.getIdentifier():gsub(':','', 'primary', nil, nil, true, nil)

-- Load the inventory content for futur use (it's like RegisterStash)
exports.core_inventory:openHolder(nil, 'torso-' .. Player.PlayerData.citizenid, 'torso', nil, nil, false, nil)

Parameters :

NameTypeDescription

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 :

exports.core_inventory:canCarry(inventory, item, amount, metadata)

Example :

exports.core_inventory:canCarry(playerid, 'water', 1)
-- OR
exports.core_inventory:canCarry('stash-'.. Player.PlayerData.citizenid, 'water', 10)
-- OR 
exports.core_inventory:canCarry('stash-'.. Player.getIdentifier():gsub(':',''), 'water', 5, { uses = 5 })

Return :

true or false if the item can be add on the inventory or not 

Parameters :

NameTypeDescription

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 :

exports.core_inventory:hasItem(inventory, item, amount)

Example :

exports.core_inventory:hasItem(playerid, 'water', 1)
-- OR
exports.core_inventory:hasItem('stash-'.. Player.PlayerData.citizenid, { 'water', 'juice' }, 40)
-- OR 
exports.core_inventory:hasItem('stash-'.. Player.getIdentifier():gsub(':',''), 'water', 5)

Return :

true or false if the item or items are present in the inventory with the requried amount

Parameters :

NameTypeDescription

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 :

exports.core_inventory:clearInventory(inventory, source)

Example :

exports.core_inventory:clearInventory(playerid, playerid)
-- OR
exports.core_inventory:clearInventory('primary-'.. Player.PlayerData.citizenid)
-- OR 
exports.core_inventory:clearInventory('stash-'.. Player.getIdentifier():gsub(':',''), source)

Parameters :

NameTypeDescription

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 :

exports.core_inventory:clearAllInventory(identifier, source)

Example :

exports.core_inventory:clearAllInventory(Player.PlayerData.citizenid, Player.source)
-- OR 
exports.core_inventory:clearAllInventory(Player.getIdentifier():gsub(':',''), source)

Parameters :

NameTypeDescription

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 :

exports.core_inventory:openLoot(source, inventoryType, lootTable, minItems, maxItems)

Example :

exports.core_inventory:openLoot(playerid, 'stash', {{"water_bottle", 30},{"weapon_assaultrifle", 5},{"iron", 50}}, 5, 20)

Parameters :

NameTypeDescription

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 :

local inventoryName, lkootGenerated = exports.core_inventory:openLootAdvanced(source, inventoryType, lootTable, addAllSameItem, inventory, shouldRegenerate)

Example :

local inventoryName, lkootGenerated = exports.core_inventory:openLootAdvanced(playerid, 'stash', 
{
        { name = "water_bottle", chance = 30, min = 3, max = 10},
        { name = "weapon_assaultrifle", chance = 5, max = 1, metadata = { ammo = 100, durability = 25.0 } },
        { name = "iron", chance = 50, min = 10, max = 20 }
}, false, nil, true)

Parameters :

NameTypeDescription

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 :

exports.core_inventory:setDurability(inventory, itemid, amount)

Example :

exports.core_inventory:setDurability('content-' .. Player.PlayerData.citizenid, 'weapon_pistol-34523', 50.0)
-- OR
exports.core_inventory:setDurability('primary-'.. Player.PlayerData.citizenid, 'weapon_pistol-34523', 100.0)
-- OR 
exports.core_inventory:setDurability('stash-'.. Player.getIdentifier():gsub(':',''), 'weapon_pistol-34523', 10)

Parameters :

NameTypeDescription

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 :

exports.core_inventory:removeDurability(inventory, itemid, amount)

Example :

exports.core_inventory:removeDurability('content-' .. Player.PlayerData.citizenid, 'weapon_pistol-34523', 50)
-- OR
exports.core_inventory:removeDurability('primary-'.. Player.PlayerData.citizenid, 'weapon_pistol-34523', 15)
-- OR 
exports.core_inventory:removeDurability('stash-'.. Player.getIdentifier():gsub(':',''), 'weapon_pistol-34523', 10)

Parameters :

NameTypeDescription

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 :

exports.core_inventory:setMetadata(inventory, slot, metadata)

Example :

exports.core_inventory:setMetadata(playerid, 1, { ammo = 50, durability = 100, serial = 'ERTDFG')
-- OR
exports.core_inventory:setMetadata('content-' .. Player.PlayerData.citizenid, 55, { ammo = 50, durability = 100, serial = 'ERTDFG')
-- OR
exports.core_inventory:setMetadata('primary-'.. Player.PlayerData.citizenid, 1, { ammo = 10, durability = 50, serial = 'XXXXX')
-- OR 
exports.core_inventory:setMetadata('stash-'.. Player.getIdentifier():gsub(':',''), 0, { ammo = 150, durability = 100, serial = 'ERT-345-1')

Parameters :

NameTypeDescription

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 :

exports.core_inventory:updateMetadata(inventory, itemid, metadata)

Example :

exports.core_inventory:updateMetadata(playerid, 'weapon_pistol-34523', { ammo = 50, durability = 100, serial = 'ERTDFG')
-- OR
exports.core_inventory:updateMetadata('content-' .. Player.PlayerData.citizenid, 'weapon_pistol-34523', { ammo = 50, durability = 100, serial = 'ERTDFG')
-- OR
exports.core_inventory:updateMetadata('primary-'.. Player.PlayerData.citizenid, 'weapon_pistol-34523', { ammo = 10, durability = 50, serial = 'XXXXX')
-- OR 
exports.core_inventory:updateMetadata('stash-'.. Player.getIdentifier():gsub(':',''), 'weapon_pistol-34523', { ammo = 150, durability = 100, serial = 'ERT-345-1')

Parameters :

NameTypeDescription

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


confiscatePlayerInventory

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

Running this export multiple time without returning the player inventory before will remove the FIRST inventory saved of the player and can't be retrive anymore. Make sure to call it just once or return the player inventory before

Usage :

exports.core_inventory:confiscatePlayerInventory(source)

Return :

true if all inventory have been saved and cleared on player
false if not (in case of error, all items will be set back to the player)

Parameters :

NameTypeDescription

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.

Running this export multiple time without returning the inventory before will remove the FIRST inventory saved and can't be retrive anymore. Make sure to call it just once or return the player inventory before

Usage :

exports.core_inventory:confiscateInventory(inventory, source, inventoryType)

Example :

exports.core_inventory:confiscateInventory('stash-'.. Player.PlayerData.citizenid, source, 'stash')
-- OR
exports.core_inventory:confiscateInventory('primary-'.. Player.PlayerData.citizenid, nil, 'primary')
-- OR 
exports.core_inventory:confiscateInventory('stash-'.. Player:getIdentifier():gsub(':',''), nil, 'stash')

Return :

true if everything is confiscated and cleared

Parameters :

NameTypeDescription

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

Calling this export will delete ALL items from the inventory. If items are in the player inventory when you did this, they will be removed and can't be retrive anymore. Make sure to call it when player inventory is empty

Usage :

exports.core_inventory:returnPlayerInventory(source)

Return :

true if all items return to the player inventories

Parameters :

NameTypeDescription

source

number

server id of the player, need to be online


returnInventory

Return all item of the confiscated inventory with confiscateInventory

Calling this export will delete ALL items from the inventory. If items are in the inventory when you did this, they will be removed and can't be retrive anymore. Make sure to call it when inventory is empty

Usage :

exports.core_inventory:returnInventory(inventory, inventoryType)

Example :

exports.core_inventory:returnInventory('stash-'.. Player.PlayerData.citizenid, 'stash')
-- OR
exports.core_inventory:returnInventory('content-'.. Player.PlayerData.citizenid, 'content')
-- OR 
exports.core_inventory:returnInventory('stash-'.. Player:getIdentifier():gsub(':',''), 'stash')

Return :

true if all items return

Parameters :

NameTypeDescription

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 :

exports.core_inventory:registerDynamicItem(itemname, itemData, force)

Example :

exports.core_inventory:registerDynamicItem('custom-water', { 
    name = 'custom-water',
    description = 'custom water use for custom thing',
    category = 'uniqueItem',
    x = 2,
    y = 2
}, true)

Parameters :

NameTypeDescription

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