Server

You don't need to change functions like AddItem, RemoveItem, GetItemByName or etc in your other scripts, you can use qb's and esx's functions

OpenCraft

exports["tgiann-inventory"]:OpenCraft(src, categoryName)
name
type
Description

src

number

Player source id

categoryName

string

Category name in configCraft.lua


OpenInventoryById

exports["tgiann-inventory"]:OpenInventoryById(playerSrc, targetSrc, showClothe)
name
type
Description

playerSrc

number

Player source id

targetSrc

number

Target player source id

showClothe

boolean

Show target's clothing inventory


ForceOpenInventoryById

Ignores config.searchPlayer settings when opening another player's inventory.

exports["tgiann-inventory"]:ForceOpenInventoryById(playerSrc, targetSrc, showClothe)
name
type
Description

playerSrc

number

Player source id

targetSrc

number

Target player source id

showClothe

boolean

Show target's clothing inventory


OpenShop

name
type
Description

src

number

Player source id

shopName

string

Products key name in configShop.lua


OpenInventory | ForceOpenInventory

Force Open Inventory has been added for those converting from Ox Inventory. Essentially, it works the same as OpenInventory, but it opens the inventory without considering values such as passwords.

Perhaps in the future, I'll migrate most functions to RegisterInventory. At that point, many of the current arguments will become obsolete, resulting in a more stable system.

name
type

src

number

invType

"glovebox" | "trunk" | "stash" | "shop" | "drop" | "crafting" | "otherplayer"

invId

"playerid" | "name" | "plate"

invData

{

maxWeight: number,

slots: number,

whitelist: string[],

blacklist: string[],

label: string,

maxAmount: Record<string, number>

jobs: string | string[]

coords: vec3 | vec3[]

}

openType

{ isPlayer: boolean, password: string }

Examples


RegisterStash

Method 1

Name
Type
Description

invId

string

playerid | name | plate

label

string

Inventory label

slots

number

Slot amount

maxweight

number

Max weight

owner

boolean

If true, the inventory is saved to the first player to open it.

groups

boolean

back compatibility for ox inv (currently not used)

coords

vector3

Stash coords

blacklist

table

Blacklist items

ex: {"bandage", "item2"}

whitelist

table

Whitelist items ex: {"bandage", "item2"}

Method 2

name
type

data

{

stashName: string,

maxWeight?: number,

slots?: number,

whitelist?: string[],

blacklist?: string[],

label?: string,

maxAmount?: Record<string, number>

jobs?: string | string[]

coords?: vec3 | vec3[]

password?: string

isPlayer?: boolean

}


LoadInventory

Return :

value
type

items

table

Parameters :

Name
Type
Description

src

int

Player source id

Example


SaveInventory

Parameters :

Name
Type
Description

src

int

Player source id


SetInventory

Parameters :

Name
Type
Description

src

int

Player source id

items

table

Player New Items


GetItemList | Items

Optionally takes the name of an item, returning only data for that item

Name
Type
Descriptioın

itemName?

string

src?

number

If itemName is provided and the item's label and description contain multi-language, the label and description will be returned according to the player's language preference. If the src value is not provided, the label and description are returned in the default language setting.

Return :

value
type

Item list or Item Data

table

Example


ItemsRaw

It has the same function as the Items export, except that if the label and description are defined with multilanguage support, it directly returns the label and description as an object.

Name
Type
Descriptioın

itemName?

string

Return :

value
type

Item list or Item Data

table

Example


GetItemLabel

Return :

value
type

İtem label

string

Parameters :

Name
Type
Description

item

string

Item spawn name

src?

number

the item's label contain multi-language, the label will be returned according to the player's language preference. If the src value is not provided, the label are returned in the default language setting.

Example


GetItem

Returns generic item data from the specified inventory, with the total count.

Return :

value
type

amount or item

number | table

Parameters :

Name
Type
Description

src

int

Player Source

item

string | table

item name or table

metadata?

table

Only returns the count of items that strictly match the given metadata.

retırms

boolean

If true, returns a value as a number.

Example


GetPlayerItems

Return :

value
type

player items

table

Parameters :

Name
Type
Description

src*

int

Player Source

Example


GetPlayerClotheItems

Return :

value
type

Player clothe items

table

Parameters :

Name
Type
Description

src*

int

Player Source

Example


GetTotalWeight

Return :

value
type

weight

int

Parameters :

Name
Type
Description

items*

table

İtem list with amount

Example


GetFreeWeight

Return :

value
type

Free weight

int

Parameters :

Name
Type
Description

src

int

Player source id

Example


GetSlotsByItem

A table containing the slots where the item was found.

Return :

value
type

slotsByItems

table

Parameters :

Name
Type
Description

items

table

Table The table containing the items.

itemName

string

string The name of the item to search for.


GetFirstSlotByItem

The slot number of the first matching item, or nil if no match is found.

Return :

value
type

SlotNumber

int or nil

Parameters :

Name
Type
Description

items

table

The table of items to search through.

itemName

string

The name of the item to search for.


SetItem

Return :

value
type

success

boolen

Parameters :

Name
Type
Description

source*

table

Player source

item*

string

item spawn name

amount*

int

the amount of item to set

Example


AddItem

Return :

value
type

success

boolen

Parameters :

Name
Type
Description

source*

table

Player source

item*

string

item spawn name

amount*

int

the amount of item to add

slot

int

slot number

metadata

table

metadata of the item modify

isClotheSlot

boolen

adds item to clothe slots

Example


RemoveItem

Return :

value
type

success

boolen

Parameters :

Name
Type
Description

source*

table

Player source

item*

string

item spawn name

amount*

int

the amount of item to add

slot

iny

slot number

metadata

table

item metadata value

Example


CloseInventory

CloseInventory function closes the player inventory

Name
Type
Description

source

int

Player source


CanCarryWeight

Returns if inventory can carry specified weight and free inventory weight.

Return :

value
type

success

boolen

Parameters :

Name
Type
Description

source

int

Player source

weight

int

Weight number


CanCarryItem / CanAddItem

Return :

value
type

success

boolen

Parameters :

Name
Type
Description

source

int

Player source

item*

string

item spawn name

amount*

int

the amount of item to check

Example


CanCarryItems

Return :

value
type

success

boolen

Parameters :

Name
Type
Description

source

int

Player source

items*

table

items table

amount*

int

the amount of item to check

Example


ClearInventory

Name
Type
Description

source

int

Player source

filterItems

null | string | string[]

item name


GetItemByName

Return :

value
type

Player Item

table

Parameters :

Name
Type
Description

source

int

Player source

item

string

Item spawn name

metadata

table

Item metadata value

Example


GetItemsByName

Return :

value
type

Player Items

Table

Parameters :

Name
Type
Description

source

int

Player source

name

string

Item name

metadata

table

Item metadata value

Example


GetItemBySlot

Return :

value
type

Player Items

Table

Parameters :

Name
Type
Description

source

int

Player source

slot

int

Slot number

metadata

table

Item metadata value

Example


GetItemCount

The total count of the specified items.

Return :

value
type
Description

count

int | nil

The total count of the specified items.

Parameters :

Name
Type
Description

source

int

The player's source ID.

items

table | string

The items to count. Can be either a table of item names or a single item name.

HasItem

Return :

value
type

Player has the item

boolen

Parameters :

Name
Type
Description

src*

int

Player source

items*

table or string

The items to check, either a string, array of strings or a key-value table of a string and number with the string representing the name of the item and the number representing the amount

amount

int

The amount of the item to check for, this will only have effect when items is a string or an array of strings

Example


RepairWeapon

Return :

value
type

Is success

boolen

Parameters :

Name
Type
Description

src*

int

Player source

slot*

int

Slot number

value

int

Repair values. Mix: 0, Max 100

Example


CreateCustomStashWithItem

Custom creates stash inventory

Return :

value
type

stashUniqId

string

items

item list

Parameters :

Name
Type
Description

stashUniqId

string

Stash name

items

table

item list

Example


GetItemByNameFromSecondaryInventory

Returns the data of the item in the stash

Return :

value
type

itemData

table

Parameters :

Name
Type
Description

invType

string

stash, trunk or glovebox

invName

string

Inventory name, id or plate

item

string

Item spawn name

metadata

table

Example


GetSecondaryInventoryItems

Returns the data of the items in the stash

Return :

value
type

Items

table

Parameters :

Name
Type
Description

invType

string

stash, trunk or glovebox

invName

string

Inventory name, id or plate

Example


RemoveItemFromSecondaryInventory

Delete items from stash

Return :

value
type

success

boolen

Parameters :

Name
Type
Description

invType

string

stash, trunk or glovebox

invName

string

Inventory name, id or plate

item

string

item spawn name

amount

int

the amount of item to add

slot

int

Slot number

metadata

table

Example


AddItemToSecondaryInventory

Add items from stash

Return :

value
type

success

boolen

Parameters :

Name
Type
Description

invType

string

stash, trunk or glovebox

invName

string

Inventory name, id or plate

item

string

item spawn name

amount

int

the amount of item to add

slot

int

Slot number

metadata

table

Example


UpdateItemMetadata / SetItemData

Updates the item's info data

Return : None

Parameters :

Name
Type
Description

src*

string

Stash uniq name

item*

string

item spawn name

slot*

string

Slot number

metadata*

table

Item new metadata

Example


DeleteInventory

deletes all data of the inventory

Return : None

Parameters :

Name
Type
Description

invType*

string

trunk, glovebox, stash

invId*

string

Inventory uniq name or plate

Example


GiveClotheItem

Return : None

Parameters :

Name
Type
Description

src*

int

Player source

model*

int

Player model (joaat("mp_f_freemode_01") or joaat("mp_m_freemode_01") )

itemName*

string

Clothe items

data*

table

Clothes data

isClotheSlot

bool

Add the item to the clothing slot

Example


RegisterShop

Return : None

Parameters :

Name
Type
Description

shopName*

string

Uniq shop name

items*

table

item list

Example


RegisterCraft

Return : None

Parameters :

Name
Type
Description

category*

string

Uniq crafting category

label*

string

Crafting menu label

items*

table

item list

Example


RegisterJobCraft

Return : None

Parameters :

Name
Type
Description

jobName*

string

Job name

label*

string

Crafting menu label

items*

table

item list

Example


RegisterGangCraft

Return : None

Parameters :

Name
Type
Description

gangName*

string

Gang name

label*

string

Crafting menu label

items*

table

item list

Example


OpenInventoryById

Opens the inventory of a player by their ID

Parameters :

Name
Type
Description

src

int

The player's server ID.

targetSrc

int

The ID of the player whose inventory will be opened.


OpenShop

Parameters :

Name
Type
Description

src

int

The player's server ID.

shopName

string

The name of the shop to open.


SetMaxWeight

Parameters :

Name
Type
Description

src

int

The player's server ID.

maxWeight

int

New max weight value


Searches the inventory for an item, or list of items, with the result varying based on the first argument.

Parameters :

Name
Type
Description

src

number

Player source id

search

string

slots | count

item

string

Item name

metadata?

table

Item metadata for search

Example


UpdateVehicle

Update the internal reference to vehicle stashes, without triggering a save or updating the database.


SaveAllInventory

This export allows you to save all currently unsaved inventories to the database.


CustomDrop

Drops can be created from other resources, containing a variety of items and utilising a custom label

Parameters :

Name
Type
Description

prefix

sring

Drop name

items

table

Items table

coords

vector3

Drop coords

slot?

number

Drop slot amount

maxWeight?

number

Drop max weight

instance?

number | string

Bucket number

Example


CreateDropFromPlayer

Creates a new drop with the contents of a player's inventory.

Parameters :

Name
Type
Description

source

number

Player id


CreateDropFromPlayerId

Used to create drops from the inventory of offline players.

Parameters :

Name
Type
Description

citizenid

string

QB: citizenid, ESX: identifer

coords

vector3

Drop location

instance

number | string

Bucket number

Last updated