Functions
The Inventory adapter provides unified inventory operations on the server side across multiple inventory systems.
Item Management Functions
registerUsableItem
Registers an item as usable.
FM.inventory.registerUsableItem(itemName, cb)
FM.framework.registerUsableItem. Both work identically.getItemLabel
Returns the display label for an item.
FM.inventory.getItemLabel(item)
The item name
Returns: string|nil - Item label or nil if not found
addItem
Adds an item to a player's inventory.
FM.inventory.addItem(src, item, amount, metadata)
Player source ID
Item name to add
Amount to add
Optional item metadata
Returns: boolean - True if item was added successfully
Example:
RegisterNetEvent('giveItem', function()
local src = source
if FM.inventory.addItem(src, "water", 5) then
print("Added 5 water bottles")
end
-- Add with metadata
FM.inventory.addItem(src, "id_card", 1, {
firstname = "John",
lastname = "Doe",
dob = "01/01/1990"
})
end)
removeItem
Removes an item from a player's inventory.
FM.inventory.removeItem(src, item, amount, slotId, metadata)
Player source ID
Item name to remove
Amount to remove
Specific slot to remove from (optional)
Specific metadata to match (optional)
Returns: boolean - True if item was removed successfully
canCarryItem
Checks if a player can carry an item (weight/space check).
FM.inventory.canCarryItem(src, item, amount)
Player source ID
Item name to check
Amount to check
Returns: boolean - True if player can carry the item
getItem
Gets information about a specific item in a player's inventory.
FM.inventory.getItem(src, item)
Player source ID
Item name to get
Returns: Item|nil - Item data or nil if not found
Item Structure:
{
name = "water",
label = "Water",
amount = 5
}
getInventory
Gets all items in a player's inventory.
FM.inventory.getInventory(src)
Player source ID
Returns: table<number, Item> - Table of items indexed by slot
Weapon Functions
addWeapon
Adds a weapon to a player's inventory.
FM.inventory.addWeapon(src, weapon, ammo)
Player source ID
Weapon name to add
Ammo count (optional, default 0)
Returns: boolean - True if weapon was added successfully
Example:
RegisterNetEvent('giveWeapon', function()
local src = source
FM.inventory.addWeapon(src, "weapon_pistol", 50)
end)
removeWeapon
Removes a weapon from a player's inventory.
FM.inventory.removeWeapon(src, weapon)
Player source ID
Weapon name to remove
Returns: boolean - True if weapon was removed successfully
getWeapon
Gets information about a weapon in a player's inventory.
FM.inventory.getWeapon(src, weapon)
Player source ID
Weapon name to get
Returns: Weapon|nil - Weapon data or nil if not found
Weapon Structure:
{
name = "weapon_pistol",
ammo = 50,
count = 1
}
Metadata Functions
getMetaDataBySlot
Gets metadata from a specific inventory slot.
FM.inventory.getMetaDataBySlot(inv, slot)
Inventory identifier (player source or inventory name)
The slot number
Returns: table|nil - Item metadata or nil if not found
setMetaDataBySlot
Sets metadata for a specific inventory slot.
FM.inventory.setMetaDataBySlot(inv, slot, metadata)
Inventory identifier (player source or inventory name)
The slot number
The new metadata to set
Returns: boolean|nil - Success status
getSlotIDByItem
Gets the first slot containing a specific item.
FM.inventory.getSlotIDByItem(inv, itemName)
Inventory identifier
The item name to find
Returns: number|nil - Slot number or nil if not found
Stash Functions
registerStash
Registers a stash for use (mainly for ox_inventory).
FM.inventory.registerStash(stash)
Stash configuration object
StashConfig Structure:
{
id = "police_evidence", -- Unique stash ID
label = "Evidence Locker", -- Display label
slots = 50, -- Number of slots
weight = 100000, -- Weight limit
owner = false, -- Owner identifier or false for shared
groups = { police = 0 }, -- Job/gang access (optional)
coords = vector3(x, y, z) -- Location (optional)
}
Example:
-- Register a shared stash
FM.inventory.registerStash({
id = "gang_stash_ballas",
label = "Ballas Stash",
slots = 100,
weight = 200000,
owner = false,
groups = { ballas = 0 }
})
-- Register a player-owned stash
FM.inventory.registerStash({
id = "player_safe_" .. identifier,
label = "Personal Safe",
slots = 50,
weight = 100000,
owner = identifier
})
upgradeStash
Upgrades a stash's weight and/or slots.
FM.inventory.upgradeStash(stashId, newWeight, newSlots)
The stash identifier to upgrade
New weight limit (optional)
New slot count (optional)
Example:
-- Upgrade stash capacity
FM.inventory.upgradeStash("player_safe_123", 150000, 75)
Exports
All inventory functions are available as exports:
exports['fmLib']:inventory_registerUsableItem(itemName, cb)
exports['fmLib']:inventory_getItemLabel(item)
exports['fmLib']:inventory_addItem(src, item, amount, metadata)
exports['fmLib']:inventory_removeItem(src, item, amount, slotId, metadata)
exports['fmLib']:inventory_canCarryItem(src, item, amount)
exports['fmLib']:inventory_getItem(src, item)
exports['fmLib']:inventory_getInventory(src)
exports['fmLib']:inventory_addWeapon(src, weapon, ammo)
exports['fmLib']:inventory_removeWeapon(src, weapon)
exports['fmLib']:inventory_getWeapon(src, weapon)
exports['fmLib']:inventory_getMetaDataBySlot(inv, slot)
exports['fmLib']:inventory_setMetaDataBySlot(inv, slot, metadata)
exports['fmLib']:inventory_getSlotIDByItem(inv, itemName)
exports['fmLib']:inventory_registerStash(stash)
exports['fmLib']:inventory_upgradeStash(stashId, newWeight, newSlots)
