UnitAddItemById

Parameters
whichUnit unit

Target unit.

itemId integer

Item's raw code identifier.

comment

Creates a new item of type itemId and puts it in unit's inventory. If the inventory is full, it is dropped on the ground at unit's position instead.

This function works in two steps:

  1. Spawn the item if both whichUnit and itemId are valid and exist
  2. Attempt to put the item in unit's inventory. If inventory is full or unit is dead then the item is dropped on the ground at unit position.

Returns:

  • item handle if the item was successfully placed in unit's inventory
  • null if inventory is full, unit cannot carry items, itemId/unit invalid etc.
note

See: UnitAddItemToSlotById.

patch

1.00

Source
common.j
return type
item
Source code
native          UnitAddItemById         takes unit whichUnit, integer itemId returns item