Server-side exports for ak47_inventory.
Adds an item to an inventory with automatic stacking and weight checks.
local success, reason = exports['ak47_inventory']:AddItem(inv, item, amount, slot, info, weight, expiretime)| Parameter | Type | Required | Description |
|---|---|---|---|
inv |
string / number | Yes | Player source ID or inventory identifier |
item |
string | Yes | Item identifier name |
amount |
number | Yes | Quantity to add |
slot |
number | No | Specific target slot index |
info |
table | No | Custom item metadata table |
weight |
number | No | Override weight per unit |
expiretime |
number | No | Override expiration timestamp |
boolean, string | number (Success flag and slot index or failure reason)Removes an item quantity from an inventory.
local success, reason = exports['ak47_inventory']:RemoveItem(inv, item, amount, slot)| Parameter | Type | Required | Description |
|---|---|---|---|
inv |
string / number | Yes | Player source ID or inventory identifier |
item |
string | Yes | Item identifier name |
amount |
number | Yes | Quantity to remove |
slot |
number | No | Specific slot index to remove from |
boolean, string (True on success, false and reason on failure)Verifies if an inventory contains required item quantities.
local hasAll, missingItems = exports['ak47_inventory']:HasItems(inv, items)| Parameter | Type | Required | Description |
|---|---|---|---|
inv |
string / number | Yes | Player source ID or inventory identifier |
items |
table | Yes | Key-value table of required items and amounts |
boolean, table (Status boolean and table of missing item counts)Retrieves consolidated item data from an inventory across all slots.
local itemData = exports['ak47_inventory']:GetItem(inv, item, info, strict)| Parameter | Type | Required | Description |
|---|---|---|---|
inv |
string / number | Yes | Player source ID or inventory identifier |
item |
string | Yes | Item identifier name |
info |
table | No | Metadata filter table |
strict |
boolean | No | Strict metadata match flag |
table or nil (Consolidated item data table)Returns total numeric count of an item in an inventory.
local total = exports['ak47_inventory']:GetAmount(identifier, item, info, strict)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Player source ID or inventory identifier |
item |
string | Yes | Item identifier name |
info |
table | No | Metadata filter table |
strict |
boolean | No | Strict metadata match flag |
number (Total item quantity)Checks whether an inventory has sufficient slots and weight capacity for an item.
local canAdd = exports['ak47_inventory']:CanAddItem(identifier, item, amount, skipWeight)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Player source ID or inventory identifier |
item |
string | Yes | Item identifier name |
amount |
number | Yes | Quantity to check |
skipWeight |
boolean | No | If true, bypasses weight limit checks |
boolean (true if item can fit, false otherwise)Checks whether an inventory contains sufficient quantity of an item.
local canRemove = exports['ak47_inventory']:CanRemoveItem(identifier, item, amount)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Player source ID or inventory identifier |
item |
string | Yes | Item identifier name |
amount |
number | Yes | Quantity to check |
boolean (true if quantity exists, false otherwise)Calculates maximum amount of an item that fits within remaining weight capacity.
local maxAmount = exports['ak47_inventory']:CanCarryAmount(identifier, item)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Player source ID or inventory identifier |
item |
string / table | Yes | Item identifier name or item data table |
number (Quantity that fits into inventory)Determines whether swapping items between inventories or slots violates weight limits.
local canSwap = exports['ak47_inventory']:CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)| Parameter | Type | Required | Description |
|---|---|---|---|
inv |
string / number | Yes | Inventory identifier |
firstItem |
table | Yes | First item data table |
firstItemCount |
number | Yes | First item quantity |
testItem |
table | Yes | Target item data table |
testItemCount |
number | Yes | Target item quantity |
boolean (true if swap is valid, false otherwise)Opens an inventory interface on the client for a specific player source.
exports['ak47_inventory']:OpenInventory(source, identifier)| Parameter | Type | Required | Description |
|---|---|---|---|
source |
number | Yes | Target player server ID |
identifier |
string | Yes | Inventory identifier to open |
Forces the inventory UI closed for a specific player source.
exports['ak47_inventory']:CloseInventory(source)| Parameter | Type | Required | Description |
|---|---|---|---|
source |
number | Yes | Target player server ID |
Initializes a new inventory in active memory.
exports['ak47_inventory']:CreateInventory(identifier, data)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string | Yes | Unique inventory identifier string |
data |
table | Yes | Table containing label, maxWeight, slots, and type |
Loads an inventory from the database or creates it if missing.
local success = exports['ak47_inventory']:LoadInventory(identifier, data)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string | Yes | Unique inventory identifier string |
data |
table | No | Default schema data if missing in database |
boolean (true if loaded successfully)Forces an immediate save of a specific inventory to the database.
exports['ak47_inventory']:SaveInventory(identifier)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Player source ID or inventory identifier |
Forces an immediate database save of all loaded inventories with pending changes.
exports['ak47_inventory']:SaveAllInventory()Wipes all item records from an inventory.
exports['ak47_inventory']:ClearInventory(identifier)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Player source ID or inventory identifier |
Unloads an inventory from memory without deleting its database record.
exports['ak47_inventory']:UnloadInventory(identifier)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier string |
Permanently removes an inventory from active memory and the database.
exports['ak47_inventory']:DeleteInventory(identifier)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier string |
Retrieves the complete data table of an inventory.
local invData = exports['ak47_inventory']:GetInventory(identifier)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Player source ID or inventory identifier |
table or nil (Inventory table or nil if not found)Retrieves an array of all items inside an inventory.
local items = exports['ak47_inventory']:GetInventoryItems(identifier)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Player source ID or inventory identifier |
table (Array of item data tables)Searches an inventory for total item counts or slot occurrences.
local result = exports['ak47_inventory']:Search(identifier, searchType, item, info)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Player source ID or inventory identifier |
searchType |
string | Yes | Search mode ('slots' or 'amount') |
item |
string / table | Yes | Single item name or array of item names |
info |
table / string | No | Metadata filter table or string match |
number or table (Item count or slot data tables)Retrieves the shared item table or a specific item's definition.
local itemDefs = exports['ak47_inventory']:Items(itemName)| Parameter | Type | Required | Description |
|---|---|---|---|
itemName |
string | No | Specific item name or nil for all items |
table (Shared item definitions or single item table)Retrieves the localized display label for an item.
local label = exports['ak47_inventory']:GetItemLabel(name)| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Item identifier name |
string (Display label)Retrieves the weapon data table currently equipped by a player.
local weaponData = exports['ak47_inventory']:GetCurrentWeapon(source)| Parameter | Type | Required | Description |
|---|---|---|---|
source |
number | Yes | Player server ID |
table or nil (Weapon item data or nil if unarmed)Checks whether an inventory has sufficient remaining capacity to carry added weight.
local canCarry = exports['ak47_inventory']:CanCarryWeight(identifier, weight)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Player source ID or inventory identifier |
weight |
number | Yes | Weight to add in grams |
boolean (true if weight fits, false otherwise)Finds the first available empty slot index in an inventory.
local slotIndex = exports['ak47_inventory']:GetEmptySlot(identifier)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Player source ID or inventory identifier |
number or nil (Slot index number or nil if full)Retrieves the sub-inventory identifier associated with a container slot (e.g. backpack).
local containerId = exports['ak47_inventory']:GetContainerFromSlot(identifier, slot)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Parent inventory identifier |
slot |
number | Yes | Slot index occupied by container item |
string or nil (Container inventory identifier string)Retrieves item data stored at a specific slot index.
local itemData = exports['ak47_inventory']:GetSlot(identifier, slot)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
slot |
number | Yes | Slot index number |
table or nil (Item data table or nil if empty)Finds the first slot containing an item or the first empty slot.
local slotIndex = exports['ak47_inventory']:GetSlotForItem(identifier, item)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
item |
string | Yes | Item identifier name |
number or nil (Slot index number)Retrieves data of the first slot containing a specific item.
local slotData = exports['ak47_inventory']:GetSlotWithItem(identifier, item, info, strict)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
item |
string | Yes | Item identifier name |
info |
table | No | Metadata filter table |
strict |
boolean | No | Strict metadata match flag |
table or nil (Slot data table)Retrieves the index number of the first slot containing a specific item.
local slotId = exports['ak47_inventory']:GetSlotIdWithItem(identifier, item, info, strict)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
item |
string | Yes | Item identifier name |
info |
table | No | Metadata filter table |
strict |
boolean | No | Strict metadata match flag |
number or nil (Slot index number)Retrieves an array of all slot data tables containing a specific item.
local slots = exports['ak47_inventory']:GetSlotsWithItem(identifier, item, info, strict)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
item |
string | Yes | Item identifier name |
info |
table | No | Metadata filter table |
strict |
boolean | No | Strict metadata match flag |
table or nil (Array of slot data tables)Retrieves an array of all slot indices containing a specific item.
local slotIds = exports['ak47_inventory']:GetSlotIdsWithItem(identifier, item, info, strict)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
item |
string | Yes | Item identifier name |
info |
table | No | Metadata filter table |
strict |
boolean | No | Strict metadata match flag |
table or nil (Array of slot index numbers)Retrieves a map of slot indices and item quantities for a specific item.
local itemSlots = exports['ak47_inventory']:GetItemSlots(identifier, item)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
item |
string | Yes | Item identifier name |
table (Key-value map of [slot] = amount)Retrieves the first found item table for an item name.
local itemData = exports['ak47_inventory']:GetFirstItem(identifier, item)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
item |
string | Yes | Item identifier name |
table or nil (First found item table)Updates custom metadata table for an item at a specific slot.
local success = exports['ak47_inventory']:SetItemInfo(identifier, slot, info)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
slot |
number | Yes | Slot index number |
info |
table | Yes | Updated metadata table |
boolean (true if updated successfully)Sets durability quality percentage for an item at a specific slot.
local success = exports['ak47_inventory']:SetQuality(identifier, slot, quality)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
slot |
number | Yes | Slot index number |
quality |
number | Yes | New quality percentage (0-100) |
boolean (true if updated successfully)Reduces durability quality percentage for an item at a specific slot.
local success = exports['ak47_inventory']:RemoveQuality(identifier, slot, amount)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
slot |
number | Yes | Slot index number |
amount |
number | Yes | Quality percentage to subtract |
boolean (true if updated successfully)Sets maximum weight capacity for an inventory.
local success = exports['ak47_inventory']:SetMaxWeight(identifier, maxWeight)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
maxWeight |
number | Yes | New maximum weight in grams |
boolean (true if updated successfully)Sets total available slot count for an inventory.
local success = exports['ak47_inventory']:SetSlotCount(identifier, slots)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
slots |
number | Yes | New maximum slot count |
boolean (true if updated successfully)Synchronizes server player inventory state to the client.
exports['ak47_inventory']:UpdatePlayerInv(source)| Parameter | Type | Required | Description |
|---|---|---|---|
source |
number | Yes | Player server ID |
Replaces the full item table of an inventory.
exports['ak47_inventory']:SetInvItems(identifier, items)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Inventory identifier |
items |
table | Yes | Array of item slot tables |
Clears equipped physical clothing items from a player.
exports['ak47_inventory']:ClearClothing(source)| Parameter | Type | Required | Description |
|---|---|---|---|
source |
number | Yes | Player server ID |
Confiscates player inventory items and stores them into a temporary stash.
local stashId = exports['ak47_inventory']:ConfiscateInventory(source)| Parameter | Type | Required | Description |
|---|---|---|---|
source |
number | Yes | Player server ID |
string (Identifier of confiscated storage stash)Restores previously confiscated items back into a player's inventory.
local success = exports['ak47_inventory']:ReturnInventory(source, identifier)| Parameter | Type | Required | Description |
|---|---|---|---|
source |
number | Yes | Player server ID |
identifier |
string | Yes | Confiscated storage identifier string |
boolean (true if inventory was restored)Registers a dynamic shop inventory on the server.
exports['ak47_inventory']:CreateShop(shopId, label, items, account)| Parameter | Type | Required | Description |
|---|---|---|---|
shopId |
string | Yes | Unique shop identifier string |
label |
string | Yes | Display title for the shop UI |
items |
table | Yes | Array of shop item tables |
account |
string | Yes | Currency account ('cash', 'bank', 'black_money') |
Configures allowed items whitelist for a specific container inventory.
exports['ak47_inventory']:SetWhitelistedItemsForContainer(identifier, items)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Container inventory identifier |
items |
table | Yes | Array of allowed item names |
Configures blocked items blacklist for a specific container inventory.
exports['ak47_inventory']:SetBlacklistedItemsForContainer(identifier, items)| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string / number | Yes | Container inventory identifier |
items |
table | Yes | Array of blocked item names |
Updates database and memory inventory identifiers when a vehicle plate changes.
exports['ak47_inventory']:OnChangeVehiclePlate(oldPlate, newPlate)| Parameter | Type | Required | Description |
|---|---|---|---|
oldPlate |
string | Yes | Original vehicle license plate string |
newPlate |
string | Yes | New vehicle license plate string |