Server
Compatibility
This script works with other popular inventory systems, like es_extended, qb-inventory, and ox_inventory
For ESX and QBCore functions, the setup is done automatically. But, if you want to keep using exports from ox_inventory or qb-inventory for compatibility, you need to turn on this option in the file: jaksam_inventory/integrations/sv_integrations.lua
Server functions
Here there are built-in exports of jaksam's inventory
addItem
Adds items to an inventory with support for metadata and specific slot placement
exports['jaksam_inventory']:addItem(inventoryId, itemName, amount, metadata, slotId)Parameters
inventoryId: string | numberThe inventory ID to add items to
Can be a player server ID or inventory ID
itemName: stringThe name of the item to add
amount: numberHow many items to add
metadata: table (optional)Additional data for the item (e.g. weapon serial, item durability)
slotId: number (optional)Specific slot to place the item in
Returns
success: booleantrue if items were added successfully
resultCode: stringError message if the operation failed
Example
canCarryItem
Checks if an inventory has space for additional items, considering both weight and slot limits
Parameters
inventoryId: string | numberThe inventory ID to check
Can be a player server ID or inventory ID
itemName: stringThe name of the item to check
amount: numberHow many items to check for
Returns
booleantrue if the inventory can carry the items
false if adding would exceed weight or slot limits
Example
canSwapItem
Checks if swapping firstItem (removing firstItemCount) with testItem (adding testItemCount) is possible
Parameters
inventoryId: string | numberThe inventory ID to check
Can be a player server ID or inventory ID
firstItem: stringThe name of the item to check
firstItemCount: numberHow many items to remove
testItem: stringThe name of the item to add
testItemCount: numberHow many items to add
Returns
booleantrue if the inventory can swap the items
false if swapping is not possible
Example
clearInventory
Removes all items from an inventory, with optional exclusion of specific items
Parameters
inventoryId: string | numberThe inventory ID to clear
Can be a player server ID or inventory ID
excludedItems: string | table (optional)Items to exclude from clearing (keep in inventory)
Can be a single item name (string) or an array of item names (table)
If not provided, all items will be removed
Returns
success: booleantrue if inventory was cleared successfully
false if inventory doesn't exist or database update failed
Example
forceOpenInventory
Forces an inventory to be opened for a specific player without permission checks
Parameters
playerId: numberThe server ID of the player who will see the inventory
inventoryId: string | numberThe inventory ID to open
Can be a player server ID (number) or inventory ID (string)
Returns
This function doesn't return any value
Example
getInventory
Gets complete data about an inventory including its items, weight limits, and metadata
Parameters
inventoryId: string | numberThe inventory ID to get data for
Can be a player server ID (number) or inventory ID (string)
Returns
inventory: table | nilTable containing the inventory data with the following structure:
Example
getItemFromSlot
Gets an item from a specific slot in an inventory
Parameters
inventoryId: string | numberThe inventory ID to get the item from
Can be a player server ID (number) or inventory ID (string)
slotId: numberThe slot number to get the item from
Returns
item: table | nilThe item in the slot, or nil if the slot is empty
Item structure:
Example
getItemByName
Gets the first item found in an inventory by its name, with optional metadata filtering
Parameters
inventoryId: string | numberThe inventory ID to search in
Can be a player server ID (number) or inventory ID (string)
itemName: stringThe name of the item to search for
metadata: table (optional)Metadata to match against when searching
If provided, only items with matching metadata will be returned
Returns
item: table | nilThe first item found matching the criteria, or nil if not found
Item structure:
slotId: number | nilThe raw slot ID where the item was found (1-based index)
nil if item not found
Example
getItemLabel
Gets the display label of an item
Parameters
itemName: stringThe name of the item to get the label for
Returns
label: string | nilThe display label of the item
nil if item doesn't exist
Example
getTotalItemAmount
Returns the total amount of a specific item in an inventory, including items in containers
Parameters
inventoryId: string | numberThe inventory ID to check
itemName: stringThe name of the item to count
metadata: table (optional)Metadata to match against when counting (if provided, only items with the same metadata AND name will be counted)
skipContainers: boolean (optional)If true, items in containers will not be counted
Returns
totalAmount: numberTotal amount of the item in the inventory, including containers (only if skipContainers is false)
totalAmountContainersExcluded: number | nilTotal amount excluding containers (only if skipContainers is false)
Example
hasItem
Checks if an inventory has a specific item
Parameters
inventoryId: string | numberThe inventory ID to check
itemName: stringThe name of the item to check
quantity: number (optional)How many items to check for
Default is 1
Returns
booleantrue if the inventory has the item
false if the inventory does not have the item
Example
registerUsableItem
Registers a callback function that will be called when an item is used Framework specific registering item will work anyway, as ESX.RegisterUsableItem and QBCore one
Parameters
itemName: stringThe name of the item to register
callback: functionFunction to call when item is used
Parameters of callback on ESX:
playerId, itemName, inventoryItem(name,metadata,amount)Parameters of callback on QBCore:
playerId, inventoryItem(name,metadata,amount, etc.)
Returns
success: booleantrue if registration was successful
Example
registerStash
Dynamically registers a new stash and creates its server inventory during runtime
Parameters
options: tableConfiguration table for the stash with the following fields:
id(string, optional): Unique ID for the stash. If not provided, one will be autogeneratedlabel(string, required): Display name for the stashcoords(vector3 | table, optional): Location where the stash can be accessed via interaction pointmaxWeight(number, optional): Maximum weight capacity. Default: 100maxSlots(number, optional): Maximum number of slots. Default: 100radius(number, optional): Distance from which players can access the stash. Default: 3.0isPrivate(boolean, optional): If true, creates a separate inventory for each player. Default: falseallowedJobs(table, optional): Table of job names that can access the stash. If nil, stash is public. Example:{police = true, sheriff = true}temporary(boolean, optional): If true, stash won't be saved to database and lost on script restart. Default: falsestartingItems(table, optional): Items to add when the stash is first created. Format:{{itemName, amount, metadata}, {itemName2, amount2, metadata2}, ...}runtimeOnly(boolean, optional): If true (default), stash can only be opened programmatically. If false and coords are provided, creates client-side interaction points (jaksam_inventory will handle also stash opening point itself) Default: true
Returns
stashId: string | nilThe ID of the created stash
nil if creation failed
Example
removeItem
Removes items from an inventory
Parameters
inventoryId: string | numberThe inventory ID to remove items from
Can be a player server ID or inventory ID
itemName: stringThe name of the item to remove
amount: numberHow many items to remove
metadata: table (optional)Metadata to match when removing items (if provided, only items with the same metadata AND name will be removed)
slotId: number (optional)Specific slot to remove items from
Returns
success: booleantrue if items were removed successfully
resultCode: stringError message if the operation failed
Example
saveDirtyInventories
Saves all modified inventories to the database
Parameters
None
Returns
success: booleantrue if all inventories were saved successfully
Example
saveDirtyInventory
Saves a specific inventory to the database if it has been modified
Parameters
inventoryId: string | numberThe ID of the inventory to save
Returns
success: booleantrue if inventory was saved successfully
Example
setInventoryMaxWeight
Sets the maximum weight capacity for an inventory
Parameters
inventoryId: string | numberThe inventory ID to modify
maxWeight: numberThe new maximum weight capacity
Returns
success: booleantrue if weight was set successfully
Example
setItemMetadataInSlot
Updates the metadata of an item in a specific inventory slot
Parameters
inventoryId: string | numberThe inventory ID containing the item
slotId: numberThe slot containing the item to update
metadata: tableThe new metadata to set
Returns
success: booleantrue if metadata was updated successfully
resultCode: stringError message if the operation failed
Example
Last updated
Was this helpful?