Operations & RPCs

Handling items securely over network

All inventory operations are routed through the UMP_InventoryManager. Operations are executed via Client-to-Server RPCs to maintain server authority.

Single-Inventory Operations

These operations modify a single inventory component. They require a valid TargetInventoryID.

  • AddItem: Adds a specified Quantity of an ItemID. If bPreferNewSlot is true, the item is placed in a new slot before attempting to stack.
  • AddItemAtSlot: Adds an item to a specific TargetSlotIndex. Fails if the slot is occupied by a different item.
  • AddItems: Accepts an array of FMP_InventoryAddItems to process multiple additions in a single RPC call.
  • RemoveItem: Removes a specified Quantity from the item at SlotIndex.
  • RemoveItemByID: Removes a specified Quantity of an ItemID. Cascades across multiple stacks if necessary.
  • UpdateItem: Overwrites the data at a specified slot with a new FMP_InventoryItem struct.
  • AdjustItemQuantity: Modifies the quantity of an item at SlotIndex by QuantityDelta.
  • SwapItems: Swaps the positions of two items at SlotIndexA and SlotIndexB within the same inventory.
  • SplitItem: Moves a specified QuantityToSplit from SourceSlotIndex to TargetSlotIndex.

Multi-Inventory Operations

These operations transfer items between two distinct inventory components.

  • SwapItemsBetweenInventories: Swaps an item from SourceInventoryID at SourceSlotIndex with an item in TargetInventoryID at TargetSlotIndex. If either component rejects the operation, the transaction is reverted to prevent data loss.
  • TransferItemBySlot: Moves a specific Quantity of an item from SourceSlotIndex to a TargetSlotIndex in another inventory. If TargetSlotIndex is -1, it auto-assigns a slot.
  • TransferItemByID: Moves a specific Quantity of an ItemID from one inventory to another, regardless of slot index.

Failure Notifications

When an operation fails (e.g., target inventory is full, insufficient permissions), the UMP_InventoryManager executes Client_OnActionNotify on the owning client. This function broadcasts OnInventoryActionNotify with an FName reason, such as:

  • Inventory Full
  • Slot Occupied
  • Item Not Found
  • Not Enough Items