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
Shared functions
Here there are built-in exports of jaksam's inventory, works both on server and client
getStaticItemsList
Returns the list of all items in the inventory
exports['jaksam_inventory']:getStaticItemsList()
Returns
items: table
The list of items, key is the item name, value is item information (label, maxStack, weight, stackable, description, rarity, type, etc.)
Example
-- Get the list of itemslocalitems=exports['jaksam_inventory']:getStaticItemsList()localweaponsCount=0foritemName, iteminpairs(items) doifitem.type=='weapon' thenweaponsCount=weaponsCount+1endendprint("There are in total " ..weaponsCount.." registered weapons in the inventory")
getStaticItem
Gets generic item information from the inventory, like weight, stackable, description, label, etc.
Parameters
itemName: string
The name of the item to get
Returns
item: table
The item information, if the item is not found, it will return nil
Example
getItemLabel
Gets only the label (display name) of an item. This is a simpler and faster alternative to getStaticItem when you only need the item's label
Parameters
itemName: string
The name of the item to get the label for
Returns
label: string|nil
The label (display name) of the item, or nil if the item is not found
Example
getItemImagePath
Gets the NUI image path for an item. The function uses a fallback system: first checks if the item has a custom image field, then tries to find .png or .webp files, and finally falls back to the default box.webp image
Parameters
itemName: string
The name of the item to get the image path for
Returns
imagePath: string
The NUI image path (e.g., "nui://jaksam_inventory/_images/bread.png"). Always returns a valid path, using fallback to box.webp if the item doesn't exist or no image is found
-- Get the information of the item "bread"
local item = exports['jaksam_inventory']:getStaticItem('bread')
print(item.label) -- Bread
print(item.weight) -- 1.0
print(item.stackable) -- true
print(item.description) -- A bread
print(item.maxStack) -- 100
print(item.rarity) -- common
print(item.type) -- item|container|ammo|currency
-- Get the label of the item "bread"
local label = exports['jaksam_inventory']:getItemLabel('bread')
print(label) -- Bread
-- Item not found returns nil
local notFound = exports['jaksam_inventory']:getItemLabel('invalid_item')
print(notFound) -- nil
-- Get the image path of the item "bread"
local imagePath = exports['jaksam_inventory']:getItemImagePath('bread')
print(imagePath) -- nui://jaksam_inventory/_images/bread.png
-- Item with custom image field
local customImage = exports['jaksam_inventory']:getItemImagePath('custom_item')
print(customImage) -- nui://jaksam_inventory/_images/custom_image.png (if item.image is set)
-- Item not found returns default box image
local notFound = exports['jaksam_inventory']:getItemImagePath('invalid_item')
print(notFound) -- nui://jaksam_inventory/_images/box.webp