BIS fnc loadInventory: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - "(Optional, default {{hl|[]}})" to "(Optional, default <sqf inline>[]</sqf>)")
 
(55 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma3
____________________________________________________________________________________________
|version1= 0.58


| arma3 |= Game name
|gr1= Inventory


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


| <pre>/*
|s1= param call [[BIS_fnc_loadInventory]]


Description:
|p1= [[Object]] - unit to receive the loadout
Add config defined inventory to an unit
|p2= [[Config]] or [[Array]] - can be one of:
* [[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


Parameter(s):
|p3= [[Array]] - (Optional, default <sqf inline>[]</sqf>) array of [[String]]s that define what part of the loadout to ignore, e.g ["weapons", "uniform"]
0: OBJECT - object which will receive the loadout
1:
CONFIG - link to CfgVehicles soldier or to CfgRespawnInventory
ARRAY in format [NAMESPACE or GROUP or OBJECT,STRING] - inventory saved using BIS_fnc_saveInventory
2: ARRAY of STRINGs - config entries to be ignored (e.g. "weapons", "uniform", ...)


Returns:
|r1= [[Boolean]]
BOOL
*/
</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_loadInventory]]; --> |= Syntax
|x1= <sqf>_loadout = [player, configFile >> "CfgVehicles" >> "B_Soldier_SL_F"] call BIS_fnc_loadInventory; // gives BLUFOR Squad Leader's loadout to player unit</sqf>


|p1= |= Parameter 1
|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>


| Bool |= Return value
|seealso= [[BIS_fnc_saveInventory]] [[BIS_fnc_exportInventory]] [[BIS_fnc_deleteInventory]] [[setUnitLoadout]]
____________________________________________________________________________________________
}}
 
|x1= <code>[soldier1, [ [[missionNamespace]], "loadout"]] [[call]] [[BIS_fnc_saveInventory]]; //save inventory into variable called "loadout".
[ [[player]], [ [[missionNamespace]], "loadout"]] [[call]] [[BIS_fnc_loadInventory]]; //load inventory from variable "loadout" onto player</code> |=
____________________________________________________________________________________________
 
| [[BIS_fnc_saveInventory]][[BIS_fnc_exportInventory]][[BIS_fnc_deleteInventory]]|= See also


{{Note
|user= Ilias38rus
|timestamp= 20200802152100
|text= Doesn't work for backpacks in backpack, unlike [[setUnitLoadout]].
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Inventory|{{uc:loadInventory}}]]
[[Category:Functions|{{uc:loadInventory}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:loadInventory}}]]

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.