Inventory

Server-side inventory functions. All functions route through the adapter for the detected inventory resource and fall back to the framework's native item API when no adapter is available.


addInventoryItem

Add an item to a player's inventory.

local ok = KOJA.Server.addInventoryItem(source, name, count, metadata, slot)
Parameter
Type
Description

source

number

Player server ID

name

string

Item name

count

number

Amount to add

metadata

table?

Item metadata (supported by ox_inventory, qs-inventory, codem-inventory, jaksam_inventory)

slot

number?

Target slot (inventory-specific)

Returns booleantrue on success.


removeInventoryItem

Remove an item from a player's inventory.

local ok = KOJA.Server.removeInventoryItem(source, name, count, metadata, slot)

Same parameters as addInventoryItem.

Returns booleantrue on success.


getInventoryItemCount

Get the total count of an item in a player's inventory.

Parameter
Type
Description

source

number

Player server ID

name

string

Item name

metadata

table?

Filter by metadata (ox_inventory only)

Returns number


HasItem

Check if a player owns at least count of an item.

Parameter
Type
Description

source

number

Player server ID

name

string

Item name

count

number?

Minimum amount (default: 1)

Returns boolean


GetPlayerInventory

Returns the player's full inventory as a flat map.

Returns table{ [itemName] = count }


Examples


Metadata & Slot Support

When using qb-inventory or a framework fallback, metadata and slot parameters are ignored.

Last updated