• Studio

  • Studio API

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Globals

    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

    Give

    ServerOnly

    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
    string
    itemId
    string
    quantity
    number

    GivePlayer

    ServerOnly

    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

    player
    itemId
    string
    quantity
    number

    Move

    ServerOnly

    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
    string
    toHolderId
    string
    itemId
    string
    quantity
    number

    MovePlayers

    ServerOnly

    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)
    

    Parameters

    fromPlayer
    toPlayer
    itemId
    string
    quantity
    number

    Release

    ServerOnly

    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
    string
    itemId
    string
    reservedFor
    string
    quantity
    number

    ReleasePlayer

    ServerOnly

    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

    player
    itemId
    string
    reservedFor
    string
    quantity
    number

    Reserve

    ServerOnly

    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
    string
    itemId
    string
    reservedFor
    string
    quantity
    number

    ReservePlayer

    ServerOnly

    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

    player
    itemId
    string
    reservedFor
    string
    quantity
    number

    Take

    ServerOnly

    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
    string
    itemId
    string
    quantity
    number

    TakePlayer

    ServerOnly

    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

    player
    itemId
    string
    quantity
    number

    Updated 13 days ago

    PocketWorlds Icon

    © 2025 Pocket Worlds. All rights reserved.