ax.item¶
Item management system for creating, storing, and managing game items.
Documented functions: 2 · Realm: server, shared
Functions¶
ax.item:Register(className, baseName, bIsBase, bAddDefaultActions)ax.item:Transfer(item, fromInventory, toInventory, placement, client, callback)
ax.item:Register(className, baseName, bIsBase, bAddDefaultActions)¶
Registers an item definition programmatically without requiring a file.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
className |
string |
The unique class identifier for the item |
baseName |
string\|nil |
The base item class to inherit from |
bIsBase |
boolean |
Whether this item is a base item |
bAddDefaultActions |
boolean |
Whether to add default take/drop actions (default true) |
Returns
table: The item definition table, or nil on failure
Source: gamemode/framework/libraries/sh_item.lua:433
ax.item:Transfer(item, fromInventory, toInventory, placement, client, callback)¶
The single transaction that moves (or repositions) an item. Every scenario that
changes an item's placement - drag-and-drop, equip, world drop/pickup, a reward
grant - goes through this; there is no other way to change ax_items.placement
/ inventory_id.
Check order: client access to both endpoints -> anti-dupe lock -> item-level
"CanTransferItem" hook -> from type's CanRemoveItem -> weight capacity + to
type's CanReceiveItem -> placement resolution/validation (skipped for
non-addressed types) -> depth-1 nesting. Memory is only mutated after the database
write confirms - failures before that point never touch self.items, so there is
nothing to roll back on a DB error, only the lock to release.
Realm: server
Parameters
| Name | Type | Description |
|---|---|---|
item |
table |
The item instance to move. |
fromInventory |
table\|number\|nil |
Source inventory (instance, id, or 0/nil for world). |
toInventory |
table\|number\|nil |
Destination inventory (instance, id, or 0/nil for world). |
placement |
table\|nil |
Target placement for addressed types - { gridX, gridY } or { slotID }. Omit to auto-place (grid types only - FindEmptySlot). |
client |
Player\|nil |
The player initiating the transfer. Nil means a trusted/system call (reward grants, admin commands, migrations) - the access gate is skipped. |
callback |
function\|nil |
Called as callback(success, reasonCode\|nil). |
Returns
boolean|nil: False on synchronous validation failure; nil once the async DB path has started (result via callback).string|nil: A phrase-key reason (e.g."inventory.reason.no_space") when returning false.
Source: gamemode/framework/libraries/sv_item.lua:92