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
addItemToTrunk
Adds items to a vehicle trunk using only the vehicle plate, automatically resolving the full inventory ID
Parameters
plate: stringThe vehicle license plate
itemName: stringThe name of the item to add
amount: numberHow many items to add
metadata: table (optional)Additional data for the item
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 (e.g., "vehicle_not_found")
notificationType: stringType of notification to show to the user
Example
Notes
Works with owned vehicles (even if not spawned/in garage)
Works with NPC vehicles (if currently spawned)
Automatically creates trunk inventory if it doesn't exist
For owned vehicles, inventory is persistent (saved to database)
addItemToGlovebox
Adds items to a vehicle glovebox using only the vehicle plate, automatically resolving the full inventory ID
Parameters
plate: stringThe vehicle license plate
itemName: stringThe name of the item to add
amount: numberHow many items to add
metadata: table (optional)Additional data for the item
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 (e.g., "vehicle_not_found")
notificationType: stringType of notification to show to the user
Example
Notes
Works with owned vehicles (even if not spawned/in garage)
Works with NPC vehicles (if currently spawned)
Automatically creates glovebox inventory if it doesn't exist
For owned vehicles, inventory is persistent (saved to database)
removeItemFromTrunk
Removes items from a vehicle trunk using only the vehicle plate, automatically resolving the full inventory ID
Parameters
plate: stringThe vehicle license plate
itemName: stringThe name of the item to remove
amount: numberHow many items to remove
metadata: table (optional)Metadata to match for removal (optional filtering)
slotId: number (optional)Specific slot to remove from
Returns
success: booleantrue if items were removed successfully
resultCode: stringError message if the operation failed
notificationType: stringType of notification to show to the user
Example
Notes
Vehicle must exist (owned vehicle in database or NPC vehicle currently spawned)
Returns false with "vehicle_not_found" if vehicle doesn't exist
removeItemFromGlovebox
Removes items from a vehicle glovebox using only the vehicle plate, automatically resolving the full inventory ID
Parameters
plate: stringThe vehicle license plate
itemName: stringThe name of the item to remove
amount: numberHow many items to remove
metadata: table (optional)Metadata to match for removal (optional filtering)
slotId: number (optional)Specific slot to remove from
Returns
success: booleantrue if items were removed successfully
resultCode: stringError message if the operation failed
notificationType: stringType of notification to show to the user
Example
Notes
Vehicle must exist (owned vehicle in database or NPC vehicle currently spawned)
Returns false with "vehicle_not_found" if vehicle doesn't exist
getInventoryIdFromPlate
Resolves the full inventory ID for a vehicle compartment using only the vehicle plate
Parameters
plate: stringThe vehicle license plate
compartment: stringEither "trunk" or "glovebox"
Returns
inventoryId: string | nilThe full inventory ID (format: "vehicle:plate:model:compartment")
nil if vehicle not found
Example
Notes
Searches in this order:
Owned vehicles database (ESX:
owned_vehicles, QBCore:player_vehicles)Existing inventories in
jaksam_inventorytableCurrently spawned vehicles (GetAllVehicles - NPC vehicles)
For owned vehicles, automatically creates inventory if it doesn't exist
Created inventories are persistent for owned vehicles, temporary for NPC vehicles
Works even if vehicle is not currently spawned (garage)
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
createInventory
Creates a new inventory in both database and memory (depending on options). If an inventory with the same ID already exists, returns the existing one without modifying it
Parameters
id: string | nilUnique identifier for the inventory. If nil, a random ID is generated
label: string | nilDisplay name for the inventory. If nil, a translation based on inventory type will be used
options: table (optional)Configuration options for the inventory:
maxWeight(number, optional): Maximum weight capacitymaxSlots(number, optional): Maximum number of slotscolumns(number, optional): Number of columns for grid display in the UI (for example you can make an inventory that's total slots is 10, but only has 2 columns, so it will be a 2x5 grid)temporary(boolean, optional): If true, the inventory is not saved to the database and will be lost on script restartprefillItems(table, optional): Random loot configuration. Items are picked via weighted selection without replacement. Structure:minTypes(number, optional): Minimum number of different item types to add. Default: 1maxTypes(number, optional): Maximum number of different item types to add. Default: pool sizeitems(table, required): Array of possible items, each entry:{name = string, chance = number, min = number, max = number, metadata = table?}name(string, required): Item namechance(number, optional): Relative weight for selection (higher = more likely). Default: 1min(number, optional): Minimum amount when picked. Default: 1max(number, optional): Maximum amount when picked. Default: 1metadata(table, optional): Metadata to attach to the item
revealItems(table, optional): Progressive item reveal animation when the inventory is opened. Items appear one by one. Structure:delayPerItem(number, optional): Milliseconds between each item reveal. Default: 1000randomOrder(boolean, optional): If true, items are revealed in random order instead of slot order. Default: false
slots(table, optional): Per-slot configuration. Key is the slot number, value is aSlotConfigtable:label(string, optional): Display label for the slot placeholderimage(string, optional): Placeholder image name shown when slot is emptyopacity(number, optional): Placeholder image opacity (0.0 - 1.0)whitelist(table, optional): Slot-level whitelist. Format:{itemName = true, ...}. Takes priority over inventory-level whitelistblacklist(table, optional): Slot-level blacklist. Format:{itemName = true, ...}. Applied before inventory whitelist
whitelist(table, optional): Inventory-level item whitelist (used as fallback if a slot has no filter). Format:{itemName = true, ...}blacklist(table, optional): Inventory-level item blacklist. Format:{itemName = true, ...}allowedJobs(table, optional): Jobs allowed to access this inventory. Format:{police = true, sheriff = true}allowedIdentifiers(table, optional): Character identifiers allowed to access this inventory. Format:{charIdentifier = true, ...}disableIncoming(boolean, optional): If true, items cannot be transferred into this inventory by the playerdisableOutgoing(boolean, optional): If true, items cannot be transferred out of this inventory by the playerdropDisabled(boolean, optional): If true, items cannot be dropped from this inventorynoLimitDrag(boolean, optional): If true, dragging ignores the amount selection dialog and moves the full stack. Used internally for shops
items: table (optional)Static items to add when the inventory is first created. Array format:
{{itemName, amount, metadata}, ...}Ignored if the inventory already exists in the database
inventoryType: string (optional)Type of inventory. Default: "stash". Other values: "player", "trunk", "glovebox"
metadata: table (optional)Additional metadata for the inventory
Returns
inventory: Inventory | nilThe created (or existing) inventory table, or nil if creation failed
Structure:
{id, label, options, items, type, totalWeight, metadata}
Example
Notes
If
idalready exists, the existing inventory is returned as is, staticitemsandprefillItemsare NOT re-appliedprefillItemsuses weighted random selection without replacement (each item type can only be picked once)prefillItemsis processed viaoptions, while staticitemsis a separate parameter. they serve different purposesUse
temporary = truefor ephemeral inventories (lootboxes, event rewards) to avoid database bloat
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
getItemsByName
Gets all items from an inventory by 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 items to search for
metadata: table (optional)Metadata to match against when searching
If provided, only items with matching metadata will be returned
strict: boolean (optional)Whether to match the metadata strictly (default: nil)
If true, all metadata fields must match exactly
Returns
items: tableArray of all items found matching the criteria
Empty table
{}if no items foundEach item in the array has the following structure:
Example
Notes
Each item includes the
slotfield indicating where it was foundUse this when you need to process multiple stacks of the same item
For single item lookups, prefer
getItemByNamefor better performance
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
setDurability
Sets the durability value of an item in a specific inventory slot
Parameters
inventoryId: string | numberThe inventory ID containing the item
Can be a player server ID or inventory ID
slotId: numberThe slot containing the item to update
durability: numberThe durability value to set (will be clamped between 0 and 100)
Returns
success: booleantrue if durability was updated successfully
resultCode: stringError message if the operation failed
Example
Last updated