InventoryTransaction
InventoryTransaction contains a list of actions that will be performed when passed to Inventory.CommitTransaction.
All methods return the InventoryTransaction instance, allowing method chaining for quick action setup.
Available operations:
- Give/GivePlayer: Add items to inventory
- Take/TakePlayer: Remove items from inventory
- Move/MovePlayers: Transfer items between holders
- Reserve/ReservePlayer: Lock items for specific purpose
- Release/ReleasePlayer: Unlock reserved items
IMPORTANT: Transactions are atomic - all operations succeed or all fail.
Methods
Adds the given quantity of the given item to the holder's inventory. Returns the transaction instance for method chaining.
local transaction = InventoryTransaction.new()
transaction:Give(player.user.id, "potion", 3)
Parameters
holderId
itemId
quantity
Returns
Adds the given quantity of the given item to the player's inventory. Convenience method equivalent to: Give(player.user.id, itemId, quantity) Returns the transaction instance for method chaining.
local transaction = InventoryTransaction.new()
transaction:GivePlayer(player, "coins", 100)
Parameters
Returns
Transfers items from one holder to another. Removes quantity from fromHolderId and adds to toHolderId. Returns the transaction instance for method chaining.
local transaction = InventoryTransaction.new()
transaction:Move(fromPlayer.user.id, toPlayer.user.id, "gold", 50)
Parameters
fromHolderId
toHolderId
itemId
quantity
Returns
Transfers items from one player to another. Convenience method equivalent to: Move(fromPlayer.user.id, toPlayer.user.id, itemId, quantity) Returns the transaction instance for method chaining.
local transaction = InventoryTransaction.new()
transaction:MovePlayers(sender, receiver, "gift", 1)
Returns
Releases previously reserved items, making them available again. The reservedFor parameter must match the one used in Reserve. Returns the transaction instance for method chaining.
local transaction = InventoryTransaction.new()
transaction:Release(player.user.id, "weapon", "equipped", 1)
Parameters
holderId
itemId
reservedFor
quantity
Returns
Releases previously reserved items for a player. Convenience method equivalent to: Release(player.user.id, itemId, reservedFor, quantity) Returns the transaction instance for method chaining.
local transaction = InventoryTransaction.new()
transaction:ReleasePlayer(player, "armor", "equipped", 1)
Parameters
Returns
Reserves items for a specific purpose, preventing them from being modified by other operations. Reserved items cannot be given, taken, or moved until released. Use the reservedFor parameter to identify the reservation purpose. Returns the transaction instance for method chaining.
local transaction = InventoryTransaction.new()
transaction:Reserve(player.user.id, "weapon", "equipped", 1)
Parameters
holderId
itemId
reservedFor
quantity
Returns
Reserves items for a specific purpose for a player. Convenience method equivalent to: Reserve(player.user.id, itemId, reservedFor, quantity) Returns the transaction instance for method chaining.
local transaction = InventoryTransaction.new()
transaction:ReservePlayer(player, "armor", "equipped", 1)
Parameters
Returns
Removes the given quantity of the given item from the holder's inventory. Returns the transaction instance for method chaining.
local transaction = InventoryTransaction.new()
transaction:Take(player.user.id, "health_potion", 1)
Parameters
holderId
itemId
quantity
Returns
Removes the given quantity of the given item from the player's inventory. Convenience method equivalent to: Take(player.user.id, itemId, quantity) Returns the transaction instance for method chaining.
local transaction = InventoryTransaction.new()
transaction:TakePlayer(player, "gems", 10)
Parameters
Returns
Updated 13 days ago