🖥️Client

EXPORTS

openInventory

Open the player inventory

Usage :

exports.core_inventory:openInventory()

Example :

exports.core_inventory:openInventory()

closeInventory

Close the player inventory

Usage :

exports.core_inventory:closeInventory()

Example :

exports.core_inventory:closeInventory()

isInventoryOpen

Return true if the player inventory isopen, false if it close

Usage :

exports.core_inventory:isInventoryOpen()

Example :

local isOpen = exports.core_inventory:isInventoryOpen()

Return :

true if it's open, false if not

getClothingItemFromPedSkin

Return the cloth items from the actual skin of the player

Usage :

exports.core_inventory:getClothingItemFromPedSkin(ped, notIncludeDefaultSkin)

Example :

local clothes = exports.core_inventory:getClothingItemFromPedSkin(PlayerPedId(), false)
-- OR
local clothes = exports.core_inventory:getClothingItemFromPedSkin(PlayerPedId(), true)
-- OR
local clothes = exports.core_inventory:getClothingItemFromPedSkin(1456273, false)

Return :

// With default skin and `notIncludeDefaultSkin` to true
[]
// With skin and `notIncludeDefaultSkin` to true
{"accessory":{"mTexture":0,"mModel":1,"mID":7},"torso":{"mTexture":0,"mModel":6,"mID":11},"tshirt":{"mTexture":1,"mModel":10,"mID":8}}
// key = item
// value = metadata

Parameters:

NameTypeDescription

ped

number

The player ped or any ped you want to get cloth item from the skin

notIncludeDefaultSkin

boolean

If false, it will also return the default skins cloth item (apply by default to the ped), if true, it won"t include it


addClothingItemFromPedSkinInInventory

Will add all the cloth from the skin player to his inventory.

Usage :

exports.core_inventory:addClothingItemFromPedSkinInInventory(ped, addAlreadyOwnCloth, notIncludeDefaultSkin, notCheckSpace)

Example :

exports.core_inventory:addClothingItemFromPedSkinInInventory(PlayerPedId(), false, true, true)
-- OR
exports.core_inventory:addClothingItemFromPedSkinInInventory(PlayerPedId(), false, true, false)

Parameters:

NameTypeDescription

ped

string or number

string : the inventory name / number : the player id

addAlreadyOwnCloth

boolean

true will also add the cloth already in player holder, false will not

notIncludeDefaultSkin

boolean

true won't add item that are from the default skin that is from the config file and not set as item

notCheckSpace

boolean

true won't check if there is enought space in inventory, false willcheck


addClothingItemFromPedSkinInClothHolder

Will add all the cloth from the skin player to the right holder directly

Usage :

exports.core_inventory:addClothingItemFromPedSkinInInventory(ped, addAlreadyOwnCloth, notIncludeDefaultSkin, notCheckSpace)

Example :

exports.core_inventory:addClothingItemFromPedSkinInInventory(PlayerPedId(), false, true, true)
-- OR
exports.core_inventory:addClothingItemFromPedSkinInInventory(PlayerPedId(), false, true, false)

Parameters:

NameTypeDescription

ped

string or number

string : the inventory name / number : the player id

addAlreadyOwnCloth

boolean

true will also add the cloth already in player holder, false will not

notIncludeDefaultSkin

boolean

true won't add item that are from the default skin that is from the config file and not set as item

notCheckSpace

boolean

true won't check if there is enought space in inventory, false willcheck


getInventory or getPlayerItems

Return all items from player content inventory

Usage :

exports.core_inventory:getInventory()

Example :

local playerItems = exports.core_inventory:getInventory()

Return :

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

search or searchInventory

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

Usage :

exports.core_inventory:search(searchType, itemsName)

Example :

exports.core_inventory:search('full', 'water_bottle')
--OR
exports.core_inventory:search('count', { 'water_bottle', 'iron' })
-- OR
exports.core_inventory:search('slot', 'water_bottle')
-- OR
exports.core_inventory:search('ids', { 'water_bottle', 'iron' })

Return :

//Full with one item
{
    "ids": [
        "water_bottle-17273686944580"
    ],
    "slots": [
        0
    ],
    "count": 2,
    "amount": 2
}
//Count with two items
{
    "water_bottle": 2,
    "iron": 5
}
//Slot with one item (slot 12)
{
    12
}

//ids with two items
{
    "iron": [
        "iron-172737995891080",
        "iron-172737995899375",
        "iron-172737995297872"
    ],
    "water_bottle": [
        "water_bottle-17273686944580"
    ]
}

Parameters:

NameTypeDescription

searchtype

string

full / count/ slot/ ids are available.

  • return all informations

  • only count

  • only slots

  • only ids

itemsName

string or table

the or all items you want to know the information in player inventory


getItemCount

Return count of the item pass in parameters

Usage :

exports.core_inventory:getItemCount(itemName)

Example :

exports.core_inventory:getItemCount('water_bottle')

Return :

//if 2 items 
2
//if 0 item
0

Parameters:

NameTypeDescription

itemName

string

name of the item you want to retrieve amount


hasItem

Return true or false if you have or not the item or items in the define amount

Usage :

exports.core_inventory:hasItem(itemsName, amount)

Example :

exports.core_inventory:hasItem('water_bottle', 2)
-- OR
exports.core_inventory:hasItem({'water_bottle', 'iron'}, 2)

Return :

//Seach for 2 water_bottle
true
//Seach for 2 water_bottle and 2 iron
true

Parameters:

NameTypeDescription

itemName

string / table

name or names of the item or items you want to know if it has enought or not

amount

number

amount of item needed (for all the item listed in itemsName)


lockInventory

Lock the inventory, it can be open or close by the player. Use unlockInventory to unlock it

Usage :

exports.core_inventory:lockInventory()

unlockInventory

Unlock player inventory (can open / close it again)

Usage :

exports.core_inventory:unlockInventory()

lockClothLock

the cloth detection. Every time you will load or open the player inventory, the cloth in cloth slot won"t be read and the skin won"t be changed. Use unlockCloth to read again the cloth items

Usage :

exports.core_inventory:lockCloth()unlockCloth

unlockCloth

Unlock the cloth holder and when the inventory will be load or open, the cloth item will be read again and overide the player skin.

Usage :

exports.core_inventory:unlockCloth()

EVENTS

core_inventory:client:itemAdd

This event is send to the client every time player receive an item

Usage :

RegisterNetEvent('core_inventory:client:itemAdd', function(itemName, amountAdded)
    -- Your code here
end)

core_inventory:client:itemRemove

This event is send to the client every time player receive an item

Usage :

RegisterNetEvent('core_inventory:client:itemRemove', function(itemName, amountRemoved)
    -- Your code here
end)

core_inventory:client:handleWeapon

This event is send to the client every time player receive an item

Usage :

RegisterNetEvent('core_inventory:client:handleWeapon', function(weaponName, weaponData, weaponInventoryamountAdded)
    -- Your code here
end)

Get inventory (callback)

Return all items present in the player inventory (content inventory only)

Usage :

QBCore.TriggerCallback('core_inventory:server:getInventory', function(inventory)
    for _, v in pairs(inventory) do
        print(v.id)
        print(v.name)
        print(v.metadata)
    end
end)

Open inventory

Open the inventory in the ui

To open private inventory no one can access with same trigger add identifier/citizenid to inventory name "cupboard-" .. Player.PlayerData.citizenid

Usage :

TriggerServerEvent('core_inventory:server:openInventory', inventoryname, inventorytype)

Example :

TriggerServerEvent('core_inventory:server:openInventory', 'content-' .. Player.PlayerData.citizenid, 'content)
-- OR
TriggerServerEvent('core_inventory:server:openInventory', 'stash-police-storage', 'stash)

Parameters :

NameTypeDescription

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 other player inventory

Can be add to your radial menu, gang script or police job script when you want to search someone

Usage :

TriggerServerEvent('core_inventory:server:openInventory', playerid, 'otherplayer', nil, nil, withCloth)

Parameters :

NameTypeDescription

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


GETTING CLOTHING

To know each value for clothing / props refer to https://wiki.rage.mp/index.php?title=Clothes

For now there are 5 ways of getting clothing to your inventory.

/giveitem (id) torso 1 {"mTorso":15,"mID":11,"mTexture":1,"mModel":14} 

Load cloth items from cloth holder

Will load the cloth from the holder cloth inventory of the player that are actually played

Usage :

TriggerServerEvent('core_inventory:server:loadClothingToPed')

Load cloth items from cloth holder from CHARACTER SELECTION screen

Will load the cloth in character selection. You need to trigger this event in your character selection script, when the player is selected in the list, after the skin is load

Usage :

# QBCore
TriggerServerEvent('core_inventory:server:loadClothingToCharacterSelection', citizenid, pedNumber)
# ESX
TriggerServerEvent('core_inventory:server:loadClothingToCharacterSelection', charPrefix, charSlot, identifierType, ped)

Example :

# QBCore in qb-multicharacter/client/main.lua 
# in function `cDataPed` after the first two
# initializePedModel function call
Wait(500)
TriggerServerEvent('core_inventory:server:loadClothingToCharacterSelection', cData.citizenid, charPed)

# ESX in esx_multicharacter/client/main.lua
# in function `` after the first two
# TriggerEvent("skinchanger:loadSkin", skin)
TriggerServerEvent('core_inventory:server:loadClothingToCharacterSelection', Config.Prefix or 'char', index)

Parameters QBCore:

NameTypeDescription

citizenid

string

Character citizenid to load the cloth

pedNumber

number

ped id to apply the cloth skin

Parameters ESX:

NameTypeDescription

charPrefix

string

Prefix of the multi character (most of the time char)

charSlot

number

slot of the player actually selected

identifierType

string

type of identifier use for player identifier (most of the time license or steam)

ped

number

ped id to apply the cloth skin

Last updated