πŸ—ƒοΈ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 stash

  • itemName (string): Item name

  • slot (number|nil): Target slot (auto-finds existing stack or next available)

  • info (table): Item metadata

  • amount (number): Quantity to add

  • invData (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 stash

  • itemName (string): Item name

  • slot (number|nil): Auto-finds if nil

  • slotIndex (number|nil): Specific item index

  • amount (number): Quantity to remove

  • invData (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 identifier

  • items (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 stash

  • newStashId (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 identifier

  • restrictionType (string): "whitelist" or "blacklist"

  • items (table): Array of item names

  • amount (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 result

    • Returns: 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 results

    • Returns: isEmpty (boolean)

  • stashId (string): The stash to check

Behavior:

  • Identical to inventory:isStashEmpty but uses TMC's callback system

  • Safer for cross-resource calls

Usage Example:


inventory:setStashId

Transfers all items from one stash to another.

Trigger Parameters:

  • stashId (string): Source stash ID

  • newStashId (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 ID

  • itemName (string): Item name to add

  • slot (number|nil): Specific slot (auto-assigns if nil)

  • info (table): Item metadata (e.g., durability, serial number)

  • amount (number): Quantity to add

  • invData (table|nil): Stash configuration for creation

    • slotCount (number): Inventory slots

    • maxWeight (number): Weight capacity

    • title (string): Display title

    • temp (boolean): Temporary stash flag

    • freezer (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:itemAdded event

Usage Example:


inventory:removeFromStash

Removes items from a stash via event.

Trigger Parameters:

  • stashId (string): Target stash ID

  • itemName (string): Item name to remove

  • slot (number|nil): Slot number (auto-finds if nil)

  • slotIndex (number|nil): Index within slot array

  • amount (number): Quantity to remove

  • invData (table|nil): Stash config if creating

Behavior:

  • Validates item exists before removal

  • Handles stackable vs non-stackable logic

  • Triggers inventory:server:itemRemoved event

  • Saves 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 ID

  • cb (function): Callback to receive items

    • Returns: items (table) - All items in stash, indexed by slot

    • Table 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 results

    • Returns: items (table) - All stash items

  • stashId (string): Target stash ID

Behavior:

  • Same functionality as inventory:getStashItems

  • Uses 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 to

  • restrictionType (string): Either "whitelist" or "blacklist"

  • items (table): Array of item names to allow/deny

  • amount (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 ID

  • cb (function): Callback to receive restriction config

    • Returns: restriction (table) or nil

    • Table structure if present:

Behavior:

  • Returns nil if no restrictions are set

  • Safe async operation

Usage Example:


inventory:clearStashItemRestriction

Removes all item restrictions from a stash via event.

Trigger Parameters:

  • id (string): Stash ID to clear restrictions from

Behavior:

  • Sets StashItemRestrictions[id] to nil

  • No validation errors if restriction doesn't exist

Usage Example:


Last updated