ποΈInventory
A list of exports and events for the inventory resource
Public Exports
addToStash
External API to add items to a stash. Handles stackable items by adding one per call iteration.
Parameters:
stashId(string): Target stashitemName(string): Item nameslot(number|nil): Target slot (auto-finds existing stack or next available)info(table): Item metadataamount(number): Quantity to addinvData(table|nil): Stash creation params{slotCount, maxWeight, title, temp, freezer}
Returns: (boolean) Success
Usage Example:
exports.inventory:addToStash('police_evidence_123', 'lockpick', nil, {}, 5)removeFromStash
External API to remove items from a stash.
Parameters:
stashId(string): Target stashitemName(string): Item nameslot(number|nil): Auto-finds if nilslotIndex(number|nil): Specific item indexamount(number): Quantity to removeinvData(table|nil): Stash creation params if stash doesn't exist
Returns: (boolean) Success
clearStash
Empties all items from a stash.
Returns: (boolean) Success
saveStash
Manually save stash state to database.
Parameters:
stashId(string): Stash identifieritems(table|nil): New items table (if provided, replaces current)force(boolean|nil): Force immediate save
Returns: (boolean) True if stash exists
getStashItems
Retrieves all items from a stash.
Returns: (table) Items table or nil if stash doesn't exist
setStashId
Copies stash contents to a new ID and clears the original.
Parameters:
stashId(string): Source stashnewStashId(string): Destination stash
Behavior:
Loads stash if not cached
Deep copies all items to new ID
Saves both stashes to database
Clears original stash with empty inventory
SetStashItemRestriction
Sets whitelist/blacklist of items allowed in a stash.
Parameters:
id(string): Stash identifierrestrictionType(string): "whitelist" or "blacklist"items(table): Array of item namesamount(number|nil): Max per slot (for whitelist)
Returns: None
GetStashItemRestriction
Retrieves restriction config for a stash.
Returns: (table) Restriction data or nil
ClearStashItemRestriction
Removes all restrictions from a stash.
Event Handlers
inventory:isStashEmpty
Event-based check if a stash is empty (temporary stashes only).
Trigger Parameters:
cb(function): Callback function to receive the resultReturns:
isEmpty(boolean) - True if stash has no items
Behavior:
Auto-loads stash if not cached
Only checks temporary stashes (returns false for non-temp)
Usage Example:
inventory:server:isStashEmpty
Server callback version for checking if a stash is empty.
Trigger Parameters:
cb(function): Callback to receive resultsReturns:
isEmpty(boolean)
stashId(string): The stash to check
Behavior:
Identical to
inventory:isStashEmptybut uses TMC's callback systemSafer for cross-resource calls
Usage Example:
inventory:setStashId
Transfers all items from one stash to another.
Trigger Parameters:
stashId(string): Source stash IDnewStashId(string): Destination stash ID
Behavior:
Deep copies all items to destination
Clears source stash with empty inventory
Saves both stashes to database immediately
Creates destination stash if not cached
Usage Example:
inventory:addToStash
Adds items to a stash via event.
Trigger Parameters:
stashId(string): Target stash IDitemName(string): Item name to addslot(number|nil): Specific slot (auto-assigns if nil)info(table): Item metadata (e.g., durability, serial number)amount(number): Quantity to addinvData(table|nil): Stash configuration for creationslotCount(number): Inventory slotsmaxWeight(number): Weight capacitytitle(string): Display titletemp(boolean): Temporary stash flagfreezer(boolean|number): Freezer multiplier
Behavior:
Creates stash if not cached
For stackable items: adds one per iteration
Applies decay/freezer effects automatically
Logs source as calling resource name
Triggers
inventory:server:itemAddedevent
Usage Example:
inventory:removeFromStash
Removes items from a stash via event.
Trigger Parameters:
stashId(string): Target stash IDitemName(string): Item name to removeslot(number|nil): Slot number (auto-finds if nil)slotIndex(number|nil): Index within slot arrayamount(number): Quantity to removeinvData(table|nil): Stash config if creating
Behavior:
Validates item exists before removal
Handles stackable vs non-stackable logic
Triggers
inventory:server:itemRemovedeventSaves stash after successful removal
Usage Example:
inventory:clearStash
Empties all items from a stash via event.
Trigger Parameters:
stashId(string): Target stash ID
Behavior:
Replaces all items with empty inventory
Saves to database immediately
Returns success status via debug output
Usage Example:
inventory:getStashItems
Retrieves all items from a stash via event callback.
Trigger Parameters:
stashId(string): Target stash IDcb(function): Callback to receive itemsReturns:
items(table) - All items in stash, indexed by slotTable structure:
items[slot][itemIndex] = {name, amount, info, slot}
Behavior:
Auto-loads stash if not cached
Returns nil if stash doesn't exist
Safe for async cross-resource calls
Usage Example:
TMC:Inventory:GetStashItems
Server callback version for retrieving stash items.
Trigger Parameters:
cb(function): Callback to receive resultsReturns:
items(table) - All stash items
stashId(string): Target stash ID
Behavior:
Same functionality as
inventory:getStashItemsUses TMC framework callback system
Better integration with other TMC systems
Usage Example:
inventory:setStashItemRestriction
Sets whitelist/blacklist item restrictions via event.
Trigger Parameters:
id(string): Stash ID to apply restriction torestrictionType(string): Either "whitelist" or "blacklist"items(table): Array of item names to allow/denyamount(number|nil): Max items per slot (for whitelist only)
Behavior:
Validates restriction type (only whitelist/blacklist allowed)
Stores in
StashItemRestrictions[id]Applied on client UI validation
Whitelist: only specified items can be added
Blacklist: specified items cannot be added
Usage Example:
inventory:getStashItemRestriction
Retrieves item restrictions for a stash via event callback.
Trigger Parameters:
id(string): Stash IDcb(function): Callback to receive restriction configReturns:
restriction(table) or nilTable structure if present:
Behavior:
Returns nil if no restrictions are set
Safe async operation
Usage Example:
inventory:clearStashItemRestriction
inventory:clearStashItemRestrictionRemoves all item restrictions from a stash via event.
Trigger Parameters:
id(string): Stash ID to clear restrictions from
Behavior:
Sets
StashItemRestrictions[id]to nilNo validation errors if restriction doesn't exist
Usage Example:
Last updated