BIS fnc loadInventory: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " \| *([^=\| ]+) * \|p1=" to " |s1= $1 |p1=")
m (Text replacement - "(Optional, default {{hl|[]}})" to "(Optional, default <sqf inline>[]</sqf>)")
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{RV|type=function
{{RV|type=function


| arma3
|game1= arma3
 
|version1= 0.58
|0.58


|gr1= Inventory
|gr1= Inventory


| Adds a predefined loadout (either via CfgVehicles, CfgRespawnInventory, or a custom inventory saved via [[BIS_fnc_saveInventory]]) to a specified unit.
|descr= Adds a predefined loadout (either via {{hl|CfgVehicles}}, {{hl|CfgRespawnInventory}}, or a custom inventory saved via [[BIS_fnc_saveInventory]]) to a specified unit.


|s1= param call [[BIS_fnc_loadInventory]]
|s1= param call [[BIS_fnc_loadInventory]]


|p1= [[Object]] - Unit to receive the loadout.
|p1= [[Object]] - unit to receive the loadout
|p2= [[Config]] - Config entry of loadout found in either CfgVehicles or CfgRespawnInventory, OR:
|p2= [[Config]] or [[Array]] - can be one of:
* [[Array]] in format [ < [[Namespace]], [[Group]] or [[Object]] >, [[String]] ] or [ output of [[BIS_fnc_saveInventory]] ] - usable with inventories saved via [[BIS_fnc_saveInventory]].
* [[Config]]: config entry of loadout found in either {{hl|CfgVehicles}} or {{hl|CfgRespawnInventory}}
* [[Array]] in format [<nowiki/>[[Namespace]], [[Group]] or [[Object]], [[String]]] or [[BIS_fnc_saveInventory]]'s output


|p3= [[Array]] - Array of [[String|Strings]] that define what part of the loadout to ignore. Example "weapons", "uniform". ''Optional parameter''.
|p3= [[Array]] - (Optional, default <sqf inline>[]</sqf>) array of [[String]]s that define what part of the loadout to ignore, e.g ["weapons", "uniform"]


|r1= [[Boolean]]
|r1= [[Boolean]]


|x1= <code>loadout = [player,configfile >> "CfgVehicles" >> "B_Soldier_SL_F"] call BIS_fnc_loadInventory; // Gives loadout of BLUFOR Squad Leader to player unit.</code>
|x1= <sqf>_loadout = [player, configFile >> "CfgVehicles" >> "B_Soldier_SL_F"] call BIS_fnc_loadInventory; // gives BLUFOR Squad Leader's loadout to player unit</sqf>


|seealso= [[BIS_fnc_saveInventory]][[BIS_fnc_exportInventory]][[BIS_fnc_deleteInventory]][[setUnitLoadout]]
|x2= to save and load the inventory:
<sqf>
[player, [missionNamespace, "TAG_SavedInventory"]] call BIS_fnc_saveInventory; // save it
[player, [missionNamespace, "TAG_SavedInventory"]] call BIS_fnc_loadInventory; // load it
</sqf>
 
|seealso= [[BIS_fnc_saveInventory]] [[BIS_fnc_exportInventory]] [[BIS_fnc_deleteInventory]] [[setUnitLoadout]]
}}
}}


<dl class="command_description">
{{Note
 
|user= Ilias38rus
<dt></dt>
|timestamp= 20200802152100
<dd class="notedate">Posted on August 8, 2015 - 17:18 (UTC)</dd>
|text= Doesn't work for backpacks in backpack, unlike [[setUnitLoadout]].
<dt class="note">[[User:Drunken Officer|Drunken Officer]]</dt>
}}
<dd class="note">
to save and load the inventory <br>
//--- save it<br>
[player, [missionNamespace, "Var_SavedInventory"]] call BIS_fnc_saveInventory;<br><br>
 
//--- load it<br>
[player, [missionNamespace, "Var_SavedInventory"]] '''call BIS_fnc_loadInventory;'''
</dd>
 
<dt><dt>
<dd class="notedate">Posted on August 2, 2020 - 15:21 (UTC)</dd>
<dt class="note">[[User:Ilias38rus|Ilias38rus]]</dt>
<dd class="note">
Doesn't work for backpacks in backpack, unlike [[setUnitLoadout]].
</dd>
</dl>

Latest revision as of 18:09, 8 November 2023

Hover & click on the images for description

Description

Description:
Adds a predefined loadout (either via CfgVehicles, CfgRespawnInventory, or a custom inventory saved via BIS_fnc_saveInventory) to a specified unit.
Execution:
call
Groups:
Inventory

Syntax

Syntax:
param call BIS_fnc_loadInventory
Parameters:
Object - unit to receive the loadout
Config or Array - can be one of:
Array - (Optional, default []) array of Strings that define what part of the loadout to ignore, e.g ["weapons", "uniform"]
Return Value:
Boolean

Examples

Example 1:
_loadout = [player, configFile >> "CfgVehicles" >> "B_Soldier_SL_F"] call BIS_fnc_loadInventory; // gives BLUFOR Squad Leader's loadout to player unit
Example 2:
to save and load the inventory:
[player, [missionNamespace, "TAG_SavedInventory"]] call BIS_fnc_saveInventory; // save it [player, [missionNamespace, "TAG_SavedInventory"]] call BIS_fnc_loadInventory; // load it

Additional Information

See also:
BIS_fnc_saveInventory BIS_fnc_exportInventory BIS_fnc_deleteInventory setUnitLoadout

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Ilias38rus - c
Posted on Aug 02, 2020 - 15:21 (UTC)
Doesn't work for backpacks in backpack, unlike setUnitLoadout.