When using the raw slot access functions, such as GetSlot() and SetSlot(), the slots are numbered
consecutively, each ItemGrid has its offset and count. To future-proff your plugins, use the named
constants instead of hard-coded numbers.
Name | Parameters | Return value | Notes |
AddItem |
cItem | cItem | AllowNewStacks | boolean |
|
|
Adds an item to the storage; if AllowNewStacks is true (default), will also create new stacks in empty slots. Fills existing stacks first and fills the hotbar before the main inventory. Returns the number of items added |
AddItems |
cItems | cItems | AllowNewStacks | boolean |
|
|
Same as AddItem, but for several items at once |
ChangeSlotCount |
SlotNum | number | AddToCount | number |
|
|
Adds AddToCount to the count of items in the specified slot. If the slot was empty, ignores the call. Returns the new count in the slot, or -1 if invalid SlotNum |
Clear |
|
|
Empties all slots |
CopyToItems |
|
|
Copies all non-empty slots into the cItems object provided; original cItems contents are preserved |
DamageEquippedItem |
|
|
Adds the specified damage (1 by default) to the currently equipped item. Removes the item and returns true if the item reached its max damage and was destroyed. |
DamageItem |
SlotNum | number | DamageAmount | number |
|
|
Adds the specified damage (1 by default) to the specified item. Removes the item and returns true if the item reached its max damage and was destroyed. |
FindItem |
|
|
Finds an item in the shield, hotbar and inventory slots matching `ItemType` and `ItemDamage`. The actual item is returned, if none is found `nullptr`. This can be used to validate that the player has a specific type of item. |
GetArmorGrid |
|
|
Returns the ItemGrid representing the armor grid (1 x 4 slots) |
GetArmorSlot |
|
|
Returns the specified armor slot contents. Note that the returned item is read-only |
GetEquippedBoots |
|
|
Returns the item in the "boots" slot of the armor grid. Note that the returned item is read-only |
GetEquippedChestplate |
|
|
Returns the item in the "chestplate" slot of the armor grid. Note that the returned item is read-only |
GetEquippedHelmet |
|
|
Returns the item in the "helmet" slot of the armor grid. Note that the returned item is read-only |
GetEquippedItem |
|
|
Returns the currently selected item from the hotbar. Note that the returned item is read-only. Also note that the returned item is bound to the actual inventory slot - if a player moves another item into the slot, this object will update to the new item. Use a cItem constructor to make a copy if you need to store the contents of the slot. |
GetEquippedLeggings |
|
|
Returns the item in the "leggings" slot of the armor grid. Note that the returned item is read-only |
GetEquippedSlotNum |
|
|
Returns the hotbar slot number for the currently selected item |
GetHotbarGrid |
|
|
Returns the ItemGrid representing the hotbar grid (9 x 1 slots) |
GetHotbarSlot |
|
|
Returns the specified hotbar slot contents. Note that the returned item is read-only |
GetInventoryGrid |
|
|
Returns the ItemGrid representing the main inventory (9 x 3 slots) |
GetInventorySlot |
|
|
Returns the specified main inventory slot contents. Note that the returned item is read-only |
GetOwner |
|
|
Returns the player whose inventory this object represents |
GetShieldSlot |
|
|
Returns current item in shield slot. |
GetSlot |
|
|
Returns the contents of the specified slot. Note that the returned item is read-only |
HasItems |
|
|
Returns true if there are at least as many items of the specified type as in the parameter |
HowManyCanFit |
ItemStack | cItem | AllowNewStacks | boolean |
|
|
Returns number of items out of a_ItemStack that can fit in the storage. If AllowNewStacks is false, only considers slots already containing the specified item. AllowNewStacks defaults to true if not given. |
HowManyCanFit |
ItemStack | cItem | BeginSlotNum | number | EndSlotNum | number | AllowNewStacks | boolean |
|
|
Returns how many items of the specified type would fit into the slot range specified. If AllowNewStacks is false, only considers slots already containing the specified item. AllowNewStacks defaults to true if not given. |
HowManyItems |
|
|
Returns the number of the specified items that are currently stored |
RemoveItem |
|
|
Removes the specified item from the inventory, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed. |
RemoveOneEquippedItem |
|
|
Removes one item from the hotbar's currently selected slot. Returns true on success. |
ReplaceOneEquippedItem |
Item | cItem | TryOtherSlots | boolean |
|
|
Removes one item from the the current equipped item stack, and attempts to add the specified item stack back to the same slot. If it is not possible to place the item in the same slot, optionally (default true) tries to place the specified item elsewhere in the inventory. Returns the number of items successfully added. If the currently equipped slot is empty, its contents are simply set to the given Item. |
SendEquippedSlot |
|
|
Sends the equipped item slot to the client |
SetArmorSlot |
ArmorSlotNum | number | cItem | cItem |
|
|
Sets the specified armor slot contents |
SetEquippedItem |
|
|
Sets current item in the equipped hotbar slot |
SetEquippedSlotNum |
|
|
Sets the currently selected hotbar slot number |
SetHotbarSlot |
HotbarSlotNum | number | cItem | cItem |
|
|
Sets the specified hotbar slot contents |
SetInventorySlot |
InventorySlotNum | number | cItem | cItem |
|
|
Sets the specified main inventory slot contents |
SetShieldSlot |
|
|
Sets the shield slot content |
SetSlot |
|
|
Sets the specified slot contents |