Soldier.addNewItem 380
Adds an item to the soldier's inventory. Weapons, and from 2.1.1 mod items too, are loaded asynchronously: the function returns true at once and the item appears a moment later. DLC items are refused.
Return value
| Return Type | Description |
|---|---|
| bool | Returns true if the item has been added to the soldier's inventory successfully |
Parameters
| Parameter | Type | Description |
|---|---|---|
| 1 | string | The id of the item to add |
| 2 | bool | (Optional) Should the soldier wear the clothing / equip the weapon. Default is false. For a mod item the prefab decides whether it can be worn. |
Examples
Example 119
local soldier = er2.getPlayer()
soldier.addNewItem("jap_infantry_helmet_4_net", true) -- Adds to the player a japanese helmet and force equips it
Equip item to soldier
local soldier = er2.getPlayer()
soldier.addNewItem("m60", true) -- Adds an M60 to the player and force equips it