Before using any player inventory methods (add_item, has_item, get_item, etc.), you must first retrieve the player inventory object using the provided export:
Copy local player = exports . list_inventory : get_player ( source ) This returns the full player inventory object, with all public methods attached.
Then you can use the methods below like so:
Copy RegisterCommand ( " give_bread " , function ( source )
local player = exports . list_inventory : get_player ( source )
if not player then
print ( " Inventory not found " )
return
end
player : add_item ( " bread " , 1 )
end ) create_player_inventory
Create a player inventory object and attach methods/data.
source (number): The player source
Player inventory object or false
Returns the inventory object for the given player.
source (number): The player source
Player inventory object or nil
Adds an item to the inventory, optionally with metadata.
amount (number): Quantity
item_data (table, optional): Item metadata (e.g., quality, serial)
true on success, or false, reason on failure
Removes item(s) by slot, ID, or metadata.
lookup (number|string|table): Slot number, item ID, or metadata table
amount (number): Amount to remove
true on success, false otherwise
Checks if inventory contains item by slot, ID, or metadata.
lookup (number|string|table): Slot number, item ID, or metadata table
amount (number): Amount required (default: 1)
true if found, otherwise false
Returns the first matching item by slot, ID, or metadata.
lookup (number|string|table): Slot number, item ID, or metadata table
Returns a table of all items in the inventory.
table: All items indexed by slot
Sets a custom data field on the inventory.
value (any): Value to store
Gets a specific or all data values from the inventory.
key (string, optional): Field name
Value of the field or full data table
Checks whether a custom data key exists.
true if exists, false otherwise
update_item_data
Updates the metadata for a specific slot.
slot (number|string): Slot number
new_data (table): New metadata to merge in
true on success, false on failure
Splits a stack in one slot into a new one.
slot (number|string): Source slot
amount (number): Amount to split
true on success, false otherwise
Removes all items from the inventory.
Saves the current inventory state to the database.
true on success, false on failure
Syncs the inventory with the client.
Last updated 7 months ago