For the complete documentation index, see llms.txt. This page is also available as Markdown.

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)

Parameters

  • src: number player source id

  • categoryName: string category name in configCraft.lua


OpenInventoryById

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

Parameters

  • playerSrc: number player source id

  • targetSrc: number target player source id

  • showClothe: boolean show the target's clothing inventory


ForceOpenInventoryById

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

Parameters

  • playerSrc: number player source id

  • targetSrc: number target player source id

  • showClothe: boolean show the target's clothing inventory


OpenShop

Parameters

  • src: number player source id

  • shopName: string products key name in configShop.lua


OpenInventory / ForceOpenInventory

ForceOpenInventory was added for those converting from Ox Inventory. It works the same as OpenInventory, but opens the inventory without considering values such as passwords.

Parameters

  • 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

Parameters

  • 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 Inventory (currently not used)

  • coords: vector3 stash coords

  • blacklist: table blacklisted items, e.g. {"bandage", "item2"}

  • whitelist: table whitelisted items, e.g. {"bandage", "item2"}

Method 2

  • 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

Parameters

  • src: number player source id

Returns

  • table items


SaveInventory

Parameters

  • src: number player source id


SetInventory

Parameters

  • src: number player source id

  • items: table player's new items


GetItemList / Items

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

Parameters

  • itemName?: string if provided, only that item's data is returned

  • src?: number if itemName is provided and its label/description have multi-language support, they're resolved to the given player's language. Without src, the default language is used

Returns

  • table the item list, or a single item's data if itemName was provided


ItemsRaw

Same as GetItemList / Items, except if the label and description are defined with multi-language support, they are returned directly as an object instead of being resolved to a single string.

Parameters

  • itemName?: string if provided, only that item's data is returned

Returns

  • table the item list, or a single item's data if itemName was provided


GetItemLabel

Parameters

  • item: string item spawn name

  • src?: number if the item's label has multi-language support, it's resolved to the given player's language. Without src, the default language is used

Returns

  • string the item's label


GetItem

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

Parameters

  • src: number player source

  • item: string or table item name or item table

  • metadata?: table only returns the count of items strictly matching this metadata

  • returnsAmount?: boolean if true, returns a number instead of a table

Returns

  • number or table amount, or item data


GetPlayerItems

Parameters

  • src: number player source

Returns

  • table player items


GetPlayerClotheItems

Parameters

  • src: number player source

Returns

  • table player clothe items


GetTotalWeight

Parameters

  • items: table item list with amount

Returns

  • number weight


GetFreeWeight

Parameters

  • src: number player source id

Returns

  • number free weight


GetSlotsByItem

Returns a table containing the slots where the item was found.

Parameters

  • items: table the table containing the items

  • itemName: string the name of the item to search for

Returns

  • table slots by item


GetFirstSlotByItem

Parameters

  • items: table the table of items to search through

  • itemName: string the name of the item to search for

Returns

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


SetItem

Parameters

  • source: number player source

  • item: string item spawn name

  • amount: number the amount of item to set

Returns

  • boolean success


AddItem

Parameters

  • source: number player source

  • item: string item spawn name

  • amount: number the amount of item to add

  • slot?: number slot number

  • metadata?: table metadata of the item to add

  • isClotheSlot?: boolean adds the item to the clothing slots

Returns

  • boolean success


RemoveItem

Parameters

  • source: number player source

  • item: string item spawn name

  • amount: number the amount of item to remove

  • slot?: number slot number

  • metadata?: table item metadata value

Returns

  • boolean success


CloseInventory

Closes the player's inventory.

Parameters

  • source: number player source


CanCarryWeight

Returns whether the inventory can carry the specified weight, and the free inventory weight.

Parameters

  • source: number player source

  • weight: number weight to check

Returns

  • boolean success


CanCarryItem / CanAddItem

Parameters

  • source: number player source

  • item: string item spawn name

  • amount: number the amount of item to check

Returns

  • boolean success


CanCarryItems

Parameters

  • source: number player source

  • items: table items table

Returns

  • boolean success


ClearInventory

Parameters

  • source: number player source

  • filterItems: nil | string | string[] item name(s) to clear. Omit to clear everything


GetItemByName

Parameters

  • source: number player source

  • item: string item spawn name

  • metadata?: table item metadata value

Returns

  • table player item


GetItemsByName

Parameters

  • source: number player source

  • name: string item name

  • metadata?: table item metadata value

Returns

  • table player items


GetItemBySlot

Parameters

  • source: number player source

  • slot: number slot number

  • metadata?: table item metadata value

Returns

  • table player item


GetItemCount

Returns the total count of the specified items.

Parameters

  • source: number player source

  • items: table or string the item(s) to count

Returns

  • number or nil total count


HasItem

Parameters

  • src: number player source

  • items: table or string the item(s) to check — a string, an array of strings, or a key-value table of item name to amount

  • amount?: number the amount to check for. Only has effect when items is a string or an array of strings

Returns

  • boolean whether the player has the item(s)


RepairWeapon

Parameters

  • src: number player source

  • slot: number slot number

  • value?: number repair value, min 0, max 100

Returns

  • boolean success


CreateCustomStashWithItem

Creates a custom stash inventory pre-filled with items.

Parameters

  • stashUniqId: string stash name

  • items: table item list


GetItemByNameFromSecondaryInventory

Returns the data of the item in the stash.

Parameters

  • invType: string stash, trunk or glovebox

  • invName: string inventory name, id or plate

  • item: string item spawn name

  • metadata?: table

Returns

  • table item data


GetSecondaryInventoryItems

Returns the data of the items in the stash.

Parameters

  • invType: string stash, trunk or glovebox

  • invName: string inventory name, id or plate

Returns

  • table items


RemoveItemFromSecondaryInventory

Removes an item from a stash.

Parameters

  • invType: string stash, trunk or glovebox

  • invName: string inventory name, id or plate

  • item: string item spawn name

  • amount: number the amount of item to remove

  • slot?: number slot number

  • metadata?: table

Returns

  • boolean success


AddItemToSecondaryInventory

Adds an item to a stash.

Parameters

  • invType: string stash, trunk or glovebox

  • invName: string inventory name, id or plate

  • item: string item spawn name

  • amount: number the amount of item to add

  • slot?: number slot number

  • metadata?: table

Returns

  • boolean success


UpdateItemMetadata / SetItemData

Updates the item's metadata.

Parameters

  • src: number player source

  • item: string item spawn name

  • slot: number slot number

  • metadata: table the item's new metadata


DeleteInventory

Deletes all data of the inventory.

Parameters

  • invType: string trunk, glovebox or stash

  • invId: string inventory unique name or plate


GiveClotheItem

Parameters

  • src: number player source

  • model: number player model (joaat("mp_f_freemode_01") or joaat("mp_m_freemode_01"))

  • itemName: string clothe item — see valid values below

  • data: table clothes data — see structure below

  • isClotheSlot?: boolean adds the item directly to the clothing slot and equips it

Valid itemName values

  • c_mask — Mask (component 1)

  • c_helmet — Helmet / Hat (prop 0)

  • c_glasses — Glasses (prop 1)

  • c_watch — Watch (prop 6)

  • c_bracelet — Bracelet (prop 7)

  • c_bproof — Body Armor (component 9)

  • c_necklace — Necklace (component 7)

  • c_ear — Earring (prop 2)

  • c_torso — Torso: top (component 11), arms (component 3), undershirt (component 8)

  • c_bag — Bag (component 5)

  • c_pants — Pants (component 4)

  • c_shoes — Shoes (component 6)

  • c_decal — Decal (component 10)

Each element of data follows this structure:

Examples


RegisterShop

Parameters

  • shopName: string unique shop name

  • items: table item list


RegisterCraft

Parameters

  • category: string unique crafting category

  • label: string crafting menu label

  • items: table item list


RegisterJobCraft

Parameters

  • jobName: string job name

  • label: string crafting menu label

  • items: table item list


RegisterGangCraft

Parameters

  • gangName: string gang name

  • label: string crafting menu label

  • items: table item list


SetMaxWeight

Parameters

  • src: number player source id

  • maxWeight: number new max weight value


Searches the inventory for an item, or a list of items. The result varies based on the first argument.

Parameters

  • src: number player source id

  • search: string slots or count

  • item: string item name

  • metadata?: table item metadata to search for


UpdateVehicle

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

Parameters

  • oldPlate: string

  • newPlate: string


SaveAllInventory

Saves all currently unsaved inventories to the database.


CustomDrop

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

Parameters

  • prefix: string drop name

  • items: table items table

  • coords: vector3 drop coords

  • slots?: number drop slot amount

  • maxWeight?: number drop max weight

  • instance?: number or string bucket number


CreateDropFromPlayer

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

Parameters

  • source: number player id


CreateDropFromPlayerId

Used to create drops from the inventory of offline players.

Parameters

  • citizenid: string QB: citizenid, ESX: identifier

  • coords: vector3 drop location

  • instance?: number or string bucket number

Last updated