Client
💻 Core Client Operations
These functions are used to check the core state of the client-side inventory or handle primary interactions.
Ready
Checks if the player's inventory system has fully loaded and is ready to be used. It's recommended to check this before performing other client-side inventory operations during script initialization.
exports['ak47_inventory']:Ready()Return: boolean
trueif ready,falseotherwise
🗃️ UI & Inventory Management
Functions for managing the inventory user interface and its state.
OpenInventory
Opens the inventory user interface. It can open a specific inventory (like a stash), a dynamically created one, or another player's inventory.
exports['ak47_inventory']:OpenInventory(data)data:
table,string, ornumberstring:target inventory identifier (e.g., 'stash:1234')number:target player server ID to open their inventorytable:Configuration data for creating and opening a temporary/dynamic inventoryidentifier(unique inventory identifier)label(display label)type(inventory type: stash, backpack, glovebox, trunk)maxWeight(maximum weight capacity)slots(total number of slots)
Example:
OpenNearbyInventory
Attempts to open the inventory of the nearest player to the client.
CloseInventory
Forces the inventory UI to close for the local player.
SetInventoryBusy
Sets the inventory's busy state, preventing or allowing the player to interact with their inventory UI. Useful when locking the inventory during an animation or progress bar.
busy:
boolean(true to lock, false to unlock)
Use Case:
🔍 Data Retrieval & Getters
Functions for reading the client's inventory state, fetching item information, and searching for items.
Items
Retrieves the shared item configuration from the client. You can use this to fetch the definition of every item or a specific item's details (label, weight, etc.).
GetItem
Retrieves a consolidated object containing data about a specific item in the player's inventory.
name:
stringitem name
info:
table(optional)filter by specific metadata
strict:
boolean(optional)if true, strictly matches info properties; otherwise uses partial matching
Return: table
item table with total item amount & properties
GetFirstItem
Finds and returns the data of the first occurrence of an item found in the inventory, regardless of how many stacks exist.
item:
stringitem name
Return: table
first found item table
GetItemLabel
Returns the friendly display label of a specific item name.
name:
stringitem name
Return: string
item label
HasItems
Verifies if the player's inventory contains a list of specific items in the required quantities.
items:
tableKey-value table of items:
{[item_name] = amount}
Return: boolean, table
hasAll (true if all items are present)
missingItems (table of missing items and the amounts still needed)
Example:
Search
A versatile search function to find item counts or full slot data in the local player's inventory.
searchType:
string'slots'(returns a table of slots where the item was found at)'amount'(returns the amount of the specified item in the player's inventory. If searching for multiple items, returns key-value pairs ofitemName = amount)
item:
tableorstringCan be a single item name or an array of item names
info:
tableorstring(optional)If info is provided as a string, it will search the item's
info.typeproperty
Amount
Slots
GetAmount
Returns the total numeric count of a specific item in the player's inventory. It sums up all stacks of that item.
itemName:
stringinfo:
table(optional)strict:
boolean(optional)Strictly match info properties, otherwise use partial matching
Return: number
total amount of the item
GetPlayerItems
Retrieves the list (table) of items currently in the local player's inventory.
Return: table
table of player items
GetPlayerWeight
Retrieves the current total weight of the items in the local player's inventory.
Return: number
current inventory weight
GetPlayerMaxWeight
Retrieves the maximum weight capacity of the local player's inventory.
Return: number
maximum inventory weight
📍 Slot Operations
Functions for interacting with specific slots in the local player's inventory.
GetSlotWithItem
Retrieves the data of the first slot found containing the specific item.
itemName:
stringinfo:
table(optional)strict:
boolean(optional)
Return: table or nil
slot data table, if found
GetSlotIdWithItem
Retrieves the slot index (ID) of the first slot found containing the specific item.
itemName:
stringinfo:
table(optional)strict:
boolean(optional)
Return: number or nil
slot ID, if found
GetSlotsWithItem
Retrieves a list of all slot data tables that contain the specific item.
itemName:
stringinfo:
table(optional)strict:
boolean(optional)
Return: table or nil
array of slot data tables
GetSlotIdsWithItem
Retrieves a list of all slot IDs containing the specific item.
itemName:
stringinfo:
table(optional)strict:
boolean(optional)
Return: table or nil
array of slot IDs
GetSlot
Retrieves the item data stored at a specific slot index in the player's inventory. Returns nil if the slot is empty.
slotId:
numberthe slot index to query
Return: table or nil
the item data table at that slot
UseSlot
Triggers the use action for the item currently occupying a specific slot.
slotId:
numberthe slot index to use
⚔️ Weapons
Functions for managing equipped weapons on the client side.
UnEquipeWeapon
Unequips the currently equipped weapon from the local player's hands.
Last updated