Events & Commands

This page is based on qb-inventory one, since we support almost all their exports to maximize the compatibility between us, qbcore and custom scripts from any developers.

Basic Events / Triggers

Open Stash:

TriggerServerEvent("inventory:server:OpenInventory", "stash", "myCustomStash", {slots = 15, maxweight = 70000})
TriggerEvent("inventory:client:SetCurrentStash", "myCustomStash")

Client Sided Event

Open Shops:

local ShopItems = {} 
ShopItems.label = "myCustomShop"
ShopItems.items =  {
            [1] = { name = "baggy_empty2", price = 32, amount = 50, info = {}, type = "item", slot = 1, },
            [2] = { name = "plantpot", price = 542, amount = 50, info = {}, type = "item", slot = 2, },
            [3] = { name = "watering_can", price = 42, amount = 50, info = {}, type = "item", slot = 3, },
            [4] = { name = "drug_fertilizer", price = 54, amount = 50, info = {}, type = "item", slot = 4, },
            [5] = { name = "rainbowbelts_seed", price = 454, amount = 50, info = {}, type = "item", slot = 5, },
            [6] = { name = "cocaine_seed", price = 532, amount = 50, info = {}, type = "item", slot = 6, },
            [7] = { name = "watering_can_high", price = 72, amount = 50, info = {}, type = "item", slot = 7, },
            [8] = { name = "drug_fertilizer_high", price = 94, amount = 50, info = {}, type = "item", slot = 8, },
}
ShopItems.slots = #ShopItems.items
ShopItems.coords = GetEntityCoords(PlayerPedId())
        
TriggerServerEvent("inventory:server:OpenInventory", "shop", "myCustomShop", ShopItems)
TriggerEvent("inventory:client:SetCurrentStash", "myCustomShop") 

Client Sided Event

Item Info

You can use SetItemData to achieve this

Items support additional information that can be added to them via an info attribute. This information will display on the item when the player hovers over it in a key,value pair format

Example:

Copy

LoadInventory

This function will retrieve the players inventory from the database via their unique identifier aka citizenid

Copy

  • source: number

  • citizenid: string

  • returns: table

Copy

SaveInventory

This function saves the players current items to the database

Copy

  • source: number

  • offline: boolean

Example:

Copy

ClearInventory

Copy

  • source: number

  • filterItems: string | table

Example:

Copy

CloseInventory

Copy

  • source: number

  • identifier: string

Example:

Copy

OpenInventory

Copy

  • source: number

  • identifier: string | optional

  • data: table | optional

Example:

Copy

OpenInventoryById

Copy

  • source: number

  • playerId: number

Example:

Copy

OpenInventoryById will close the target players inventory (if open) and lock it via state. It will then unlock when the opening player closes it

CreateShop

Copy

  • shopData: table

Copy

Coords being passed to createShop will be checked against the player's current coords when OpenShopis called if coords were provided during createShop

OpenShop

Copy

  • source: number

  • name: string

Copy

AddItem

Copy

  • identifier: number

  • item: string

  • amount: number

  • slot: number | boolean

  • info: table | boolean

  • reason: string

  • returns: boolean

Example:

Copy

RemoveItem

Copy

  • identifier: number

  • item: string

  • amount: number

  • slot: number | boolean

  • reason: string

  • returns: boolean

Copy

SetInventory

Copy

  • source: number

  • items: table

Example:

Copy

SetItemData

This function uses GetItemByName to find the itemName being passed

Copy

  • source: number

  • itemName: string

  • key: string

  • val: string | table

  • returns: boolean

Example:

Copy

Item Info Example:

Copy

UseItem

Copy

  • itemName: string

  • . . . : function

Example:

Copy

HasItem

This export is also available to use on the client

Copy

  • source: number

  • items: string | table

  • amount: number

  • returns: boolean

Example:

Copy

GetSlotsByItem

Copy

  • items: table

  • itemName: string

  • returns: table

Example:

Copy

GetFirstSlotByItem

Copy

  • items: table

  • itemName: string

  • returns: number

Example:

Copy

GetItemBySlot

Copy

  • source: number

  • slot: number

  • returns: table

Example:

Copy

GetItemByName

Copy

  • source: number

  • item: string

  • returns: table

Example:

Copy

GetItemsByName

Copy

  • source: number

  • item: string

  • returns: table

Example:

Copy

SetUsage

Copy

  • state: bool

Example:

Copy

GetUsageState

Copy

  • return: bool

Example:

Copy

GetInventory

Copy

  • source: number

  • returns: table

Example:

Copy

CanAddItem

Copy

  • source: number

  • item: string

  • count: number

  • returns: bool

Example:

Copy

GetStashItems

Copy

  • stashID: string

  • returns: table

Example:

Copy

GetItemDecayHealth

Copy

  • itemData: table

  • returns: number

Example:

Copy

EXCLUSIVE EXPORTS JUST FOR ESX!

We need this exports because ESX inventory system, by default, is very simple ( non slots based inventory ), so we need futher mods to it work perfect.

SetPlayerData

Copy

  • key: string ("craftingrep", "items")

  • param: table

  • source: number

Example:

Copy

GetItemList

Copy

  • returns: table

Example:

Copy

GetItemLabel

Copy

  • itemName: string

  • returns: string

Example:

Copy

CraftLevel

Copy

  • returns: number

Example:

Copy

Client Sided Export

GetInventoryOldFormat

Copy

  • returns: DEFAULT_ESX_INVENTORY_TABLE_(converted from jpr to esx format)

Example:

Copy

Client Sided Export

Last updated