UnitAddItemToSlotById
- Parameters
-
whichUnit unit
Target unit.
itemId integer
Item's raw code identifier.
itemSlot integer
Slot number (zero-based, i.e. 0 to 5).
- comment
-
Creates a new item of type
itemId
and puts it in unit's inventory in slot specified byitemSlot
. If the slot is occupied or invalid (<0 or >6, or higher than unit's max slots), it is dropped on the ground at unit's position instead.This function works in two steps:
- Spawn the item if both
whichUnit
anditemId
are valid and exist - Attempt to put the item in unit's inventory at specified slot. If the slot is occupied or unit is dead then the item is dropped on the ground at unit position.
Returns:
- true if the item was successfully placed in unit's inventory
- false otherwise: slot occupied, unit cannot carry items, itemId/unit/itemSlot invalid etc.
- Spawn the item if both
- note
-
See:
UnitAddItemById
. - patch
-
1.00
- Source
- common.j (suggest an edit or discuss on Github)
- return type
-
boolean
- Source code
-
native UnitAddItemToSlotById takes unit whichUnit, integer itemId, integer itemSlot returns boolean