BlackICE Scripting

class re

Inventory

re.Inventory

  • 0 properties
  • 25 functions

Properties

None.

Functions

  • static re.AddItemResult AddItem(re.InventoryId inventory, TDBID record, uint quantity) staticextension

    Adds new items of a record with the record's default stats, the way the game creates them. A stackable record adds to its stack, any other record adds that many unique items with random seeds. On a player inventory the client creates the items and reports them back, and in approval mode the stats it generates for them wait for approval with a Generated event. Returns the added items, or the status saying why nothing was added

    record
    Item record, for example Items.Preset_Lexington_Default
    quantity
    For a stackable record the amount added to its stack, otherwise the number of unique items
  • static re.AddItemResult AddItemData(re.InventoryId inventory, byte[] data) staticextension

    Adds an item from GetItemData, rebuilt exactly. If the inventory already contains a unique item with the same identity, the new one gets a new unique counter, which the result lists. On a player inventory the client creates it and reports it back, with approval working as for AddItemInfo. Returns the added item, or the status saying why nothing was added

  • static re.AddItemResult AddItemInfo(re.InventoryId inventory, re.ItemInfo item) staticextension

    Adds an item built from an ItemInfo, for example one changed after GetItem. The seed decides its rolls, and its modifiers and parts replace the defaults. Without modifiers, parts and loot record the client creates it fresh from the record and seed. The identity has to match what the game gives the record (see ItemInfo.seed). On a player inventory the client creates the item and reports it back. In approval mode the stats it generates for a fresh item will trigger a Generated event, a rebuilt item that comes back different triggers an Updated event. Returns the added item, or the status saying why nothing was added

  • static bool Approve(uint transaction) staticextension

    Approves one change from InventoryChangeRequested. A move is validated again when it's approved, so it can still be refused if things changed while the bundle decided, for example if someone else took the item first, the client closed the inventory or walked out of range, or the inventory is now full. A drop goes ahead once all of its items are approved. Returns false if the transaction is unknown, already answered or timed out

  • bool[] Approve(uint[] transactions) staticextension

    Approves several changes from InventoryChangeRequested at once, for example every change of an event. Returns one result per transaction, false where Approve would return false

  • static re.InventoryId Create() staticextension

    Creates an empty inventory owned by the server. It exists until Destroy, even after the bundle that created it unloads, and any bundle can use it. The contents are only kept in memory, so persist them yourself if needed

  • static bool Destroy(re.InventoryId inventory) staticextension

    Destroys an inventory and everything in it (InventoryDestroyed). Clients that have it open see it empty, and moves waiting for approval are refused. Returns false for player inventories, player stashes, and the inventories of loot containers and drops, which go away with their entity

  • static bool Equip(re.InventoryId inventory, re.ItemRef item, int slot) staticextension

    Equips an item on a player. The client equips it once it has the item, which includes items just given with AddItem, AddItemData or AddItemInfo. The item's record decides the equipment area. Returns false if the inventory isn't the player inventory of a connected client

    slot
    Slot index in the item's equipment area, for example 0 to 2 for the three weapon slots, or -1 for the first free slot.
  • static re.EquippedItem[] GetEquipped(re.InventoryId inventory) staticextension

    Returns what a player has equipped, as their client reported it, limited to items in their inventory. Empty for other inventories. When the player gets a new puppet, for example after changing body gender, this loadout is equipped again

  • static re.ItemInfo? GetItem(re.InventoryId inventory, re.ItemRef item) staticextension

    Returns the full item with its identity, loot stats, saved stat modifiers and installed parts, or null if the inventory doesn't contain it

  • static byte[] GetItemData(re.InventoryId inventory, re.ItemRef item) staticextension

    Returns the full item as bytes, for example to store it in a database. The data contains everything GetItem shows plus details GetItem can't express, and AddItemData restores it exactly. Empty if the inventory doesn't contain the item

  • static re.InventoryEntry[] GetItems(re.InventoryId inventory) staticextension

    Returns the stacks an inventory contains

  • static re.EntityId GetLinkedEntity(re.InventoryId inventory) staticextension

    Returns the entity the inventory is linked to, or an invalid id if there is none

  • static re.InventoryId GetPlayerInventory(re.ClientId client) staticextension

    Returns a client's own inventory, which the server keeps in sync with what the client reports. The id is 0 until the client sends its inventory shortly after joining (PlayerInventoryCreated). AddItem and RemoveItem are applied by the client, while Open, Destroy and LinkToEntity are refused. When the client leaves, the inventory can still be read in ClientDisconnecting handlers, so save it there. After that it can't be changed anymore and is destroyed (InventoryDestroyed)

  • static re.InventoryId GetPlayerStash(re.ClientId client) staticextension

    Returns a client's stash, a single inventory per client that every stash in the game shows. It exists from the moment the client joins, and the best place to restore it is PlayerInventoryCreated, together with the player inventory. Moves in and out work like with any other inventory, including events and approval mode, but the server can't tell whether the player is actually near a stash. When the client leaves, the stash can still be read in ClientDisconnecting handlers, so save it there. After that it can't be changed anymore and is destroyed. Destroy and LinkToEntity are refused

  • static bool LinkToEntity(re.InventoryId inventory, re.EntityId entity) staticextension

    Links the inventory to an entity, for example a car for its trunk. Clients can then only open it and move items within 5 m of the entity. If the entity goes away, the inventory stays and InventoryUnlinked is raised. Returns false for player inventories, player stashes, and the inventories of loot containers and drops, which belong to their entity

  • static bool Open(re.ClientId client, re.InventoryId inventory) staticextension

    Opens the inventory for a client in the storage screen, next to the client's own inventory. Moves between the two go through the server. Any inventory except a player inventory can be opened, including another client's stash, which is useful for admin tools. Linked inventories, which includes those of loot containers and drops, only open within 5 m of their entity. Returns false if the client isn't connected, the inventory is a player inventory or is going away, or the client is out of range

  • static bool Reject(uint transaction) staticextension

    Rejects one change from InventoryChangeRequested. A move or drop is refused, and rejecting one item of a drop refuses the whole drop. An item the client already has (Added, Initial) is removed, a changed item (Updated) goes back to the server's copy, and a claimed item stays out of the world inventory. For Generated (i.e. the phase where the item was given by the server, but no client has rolled stats on it yet), a unique item is removed and a stack goes back to its record's state. Mods the client installed into a rejected item are given back. Returns false if the transaction is unknown, already answered or timed out

  • bool[] Reject(uint[] transactions) staticextension

    Rejects several changes from InventoryChangeRequested at once. Returns one result per transaction, false where Reject would return false

  • static bool RemoveItem(re.InventoryId inventory, TDBID record, uint quantity) staticextension

    Removes items of a record, from its stack for a stackable record and otherwise any unique items of it. Removes nothing and returns false if the inventory contains fewer. On a player inventory the client removes them and reports it back

  • static bool RemoveItemExact(re.InventoryId inventory, re.ItemRef item, uint quantity) staticextension

    Removes a quantity of exactly this item (see InventoryEntry.ToRef). Removes nothing and returns false if the inventory contains fewer. On a player inventory the client removes it and reports it back

  • static void SetApprovalMode(bool enabled) staticextension

    Turns server-wide approval mode on or off. While it is on, everything a client does that puts items into a server-side inventory waits for a bundle to answer InventoryChangeRequested. That includes moves, drops, items the game adds to a player, changed items, the inventory a player joins with, loot rolls, and the stats a client generates for items the server created. Answer with Approve or Reject within 5 s, otherwise the change is rejected. If no bundle handles InventoryChangeRequested, everything is approved. Items given through the API are added without approval, only the stats the client reports for them wait. Turning approval mode off approves everything that is still waiting

  • static void SetStarterItems(re.StarterItemsMode mode) staticextension

    Sets which new player puppets get the game's starting build with its items and clothing. It is Always by default. The build's items arrive like any other add (InventoryChanged, or waiting for approval in approval mode)

  • static bool Unequip(re.InventoryId inventory, EquipmentArea area, int slot) staticextension

    Unequips what a player has in a slot of an equipment area. The item stays in the inventory. Returns false if the inventory isn't the player inventory of a connected client

    slot
    Slot index in the area, or -1 for every slot in it