setUnitLoadout: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "{{uc:{{PAGENAME}}}} " to "")
m (Text replacement - "\[ +" to "[")
 
(25 intermediate revisions by 2 users not shown)
Line 10: Line 10:
|gr1= Unit Inventory
|gr1= Unit Inventory


|descr= Creates a loadout from given inventory structure and applies it to a unit. When [[String]] for class name is supplied, the command will search <tt>CfgVehicles</tt> for the given class in order to extract the loadout from config. If [[Config]] is given, it will search given config (including [[missionConfigFile | mission config]]) for the loadout information. In either case, the config should contain the following entries, which is standard for any unit class, for example:
|descr= Creates a loadout from given inventory structure and applies it to a unit. When [[String]] for class name is supplied, the command will search {{hl|CfgVehicles}} for the given class in order to extract the loadout from config. If [[Config]] is given, it will search given config (including [[missionConfigFile | mission config]]) for the loadout information. In either case, the config should contain the following entries, which is standard for any unit class, for example:
<syntaxhighlight lang=cpp>
<syntaxhighlight lang="cpp">
class MyLoadout
class MyLoadout
{
{
Line 37: Line 37:
|p22= loadout: [[Array]] - [[Unit Loadout Array]]
|p22= loadout: [[Array]] - [[Unit Loadout Array]]


|p23= fullMagazines: [[Boolean]] - Partially emptied magazines will be refilled when the loadout is applied
|p23= fullMagazines: [[Boolean]] - partially emptied magazines will be refilled when the loadout is applied


|r2= [[Nothing]]
|r2= [[Nothing]]
Line 45: Line 45:
|p41= unit: [[Object]]
|p41= unit: [[Object]]


|p42= name: [[String]] - Class name (see description)
|p42= name: [[String]] - class name (see description)


|r3= [[Nothing]]
|r3= [[Nothing]]
Line 53: Line 53:
|p61= unit: [[Object]]
|p61= unit: [[Object]]


|p62= config: [[Config]] - Config class (see description)
|p62= config: [[Config]] - config class (see description)


|r4= [[Nothing]]
|r4= [[Nothing]]


|x1= <code>player_2 [[setUnitLoadout]] ([[getUnitLoadout]] player_1); // Copies loadout from player_1 and applies it to player_2 </code>
|x1= <sqf>player_2 setUnitLoadout (getUnitLoadout player_1); // Copies loadout from player_1 and applies it to player_2</sqf>


|x2= <code>player_2 [[setUnitLoadout]] [<nowiki/>[[getUnitLoadout]] player_1, [[true]]]; // Copies loadout from player_1 and applies it to player_2 while topping up all magazines</code>
|x2= <sqf>player_2 setUnitLoadout [getUnitLoadout player_1, true]; // Copies loadout from player_1 and applies it to player_2 while topping up all magazines</sqf>


|x3= <code>_unit [[setUnitLoadout]] "B_Soldier_F";</code>
|x3= <sqf>_unit setUnitLoadout "B_Soldier_F";</sqf>


|x4= <code>_unit [[setUnitLoadout]] ([[configFile]] >> "CfgVehicles" >> "B_Soldier_F");</code>
|x4= <sqf>_unit setUnitLoadout (configFile >> "CfgVehicles" >> "B_Soldier_F");</sqf>


|x5= <code>_unit [[setUnitLoadout]] ([[missionConfigFile]] >> "MyLoadout");</code>
|x5= <sqf>_unit setUnitLoadout (missionConfigFile >> "MyLoadout");</sqf>


|x6= Strip unit of everything {{Since|arma3|1.94|y}}<code>_unit [[setUnitLoadout]] ([[configFile]] >> "EmptyLoadout");</code>
|x6= Strip unit of everything:
<sqf>_unit setUnitLoadout (configFile >> "EmptyLoadout");</sqf>


|seealso= [[getUnitLoadout]]
|seealso= [[getUnitLoadout]]
Line 73: Line 74:




{{GameCategory|arma3|Scripting Commands}}
<dl class="command_description">
{{GameCategory|arma3|New Scripting Commands}}
 


<dl class="command_description">
<dt></dt>
<dt></dt>
<dd class="notedate">Posted on December 17, 2019 - 23:08 (UTC)</dd>
<dd class="notedate">Posted on 2019-12-17 - 23:08 (UTC)</dd>
<dt class="note">[[User:demellion|demellion]]</dt>
<dt class="note">[[User:demellion|demellion]]</dt>
<dd class="note">
<dd class="note">
'''NOTE:''' Empty or used magazines in loadouts will be refilled under specific circumstance, even if the refill argument is [[false]]. This seems to happen if amount of used magazines is 2 or more.
'''NOTE:''' Empty or used magazines in loadouts will be refilled under specific circumstance, even if the refill argument is [[false]]. This seems to happen if amount of used magazines is 2 or more.
<code>player setUnitLoadout [
<sqf>player setUnitLoadout [
["arifle_MX_ACO_pointer_F","","acc_pointer_IR","optic_Aco",[],[],""],
["arifle_MX_ACO_pointer_F","","acc_pointer_IR","optic_Aco",[],[],""],
[],
[],
["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""],
["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""],
["U_B_CombatUniform_mcam",[ ["30Rnd_65x39_caseless_mag",1,1] ]],
["U_B_CombatUniform_mcam",[["30Rnd_65x39_caseless_mag",1,1]]],
["V_PlateCarrier1_rgr",[]],
["V_PlateCarrier1_rgr",[]],
["B_AssaultPack_mcamo_Ammo",[]],
["B_AssaultPack_mcamo_Ammo",[]],
"H_HelmetB_grass","",[],["ItemMap","","ItemRadio","ItemCompass","ItemWatch","NVGoggles"]
"H_HelmetB_grass","",[],["ItemMap","","ItemRadio","ItemCompass","ItemWatch","NVGoggles"]
]</code>
]</sqf>
Will result in 30Rnd magazine with one bullet in it.
Will result in 30Rnd magazine with one bullet in it.
<code>player setUnitLoadout [
<sqf>player setUnitLoadout [
["arifle_MX_ACO_pointer_F","","acc_pointer_IR","optic_Aco",[],[],""],
["arifle_MX_ACO_pointer_F","","acc_pointer_IR","optic_Aco",[],[],""],
[],
[],
["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""],
["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""],
["U_B_CombatUniform_mcam",[ ["30Rnd_65x39_caseless_mag",2,1] ]],
["U_B_CombatUniform_mcam",[["30Rnd_65x39_caseless_mag",2,1]]],
["V_PlateCarrier1_rgr",[]],
["V_PlateCarrier1_rgr",[]],
["B_AssaultPack_mcamo_Ammo",[]],
["B_AssaultPack_mcamo_Ammo",[]],
"H_HelmetB_grass","",[],["ItemMap","","ItemRadio","ItemCompass","ItemWatch","NVGoggles"]
"H_HelmetB_grass","",[],["ItemMap","","ItemRadio","ItemCompass","ItemWatch","NVGoggles"]
]</code>
]</sqf>
Will result in 2 magazines but full, 30 rounds in it. This applies to any magazines count >2. They will never be with specified amount of rounds, even if you force the refill argument to [[false]]
Will result in 2 magazines but full, 30 rounds in it. This applies to any magazines count >2. They will never be with specified amount of rounds, even if you force the refill argument to [[false]]
</dd>
</dd>
<dt><dt>
<dt><dt>
<dd class="notedate">Posted on October 23, 2020 - 21:16 (UTC)</dd>
<dd class="notedate">Posted on 2020-10-23 - 21:16 (UTC)</dd>
<dt class="note">[[User:Andrew_S90|Andrew_S90]]</dt>
<dt class="note">[[User:Andrew_S90|Andrew_S90]]</dt>
<dd class="note">
<dd class="note">
Line 112: Line 111:
Pass a loadout to your compiled command and it will provide one back that will not refill ammo
Pass a loadout to your compiled command and it will provide one back that will not refill ammo
</dd>
</dd>
</dl>
</dl>
{{Note
|user= POLPOX
|timestamp= 20220823082709
|text= <sqf>player setUnitLoadout [
nil,
nil,
nil,
nil,
nil,
["B_Bergen_sgg",nil],
nil, nil, nil,
nil
];</sqf>You can use [[nil]] to skip some desired parameter. The skipped part will be ignored and remain the same with old loadout.<br/>
This method is ''very slightly'' faster than the latter method:
<sqf>private _loadout = getUnitLoadout player;
_loadout#5 set [0,"B_Bergen_mcamo_F"];
player setUnitLoadout _loadout;</sqf>
}}

Latest revision as of 19:18, 8 November 2023

Hover & click on the images for description

Description

Description:
Creates a loadout from given inventory structure and applies it to a unit. When String for class name is supplied, the command will search CfgVehicles for the given class in order to extract the loadout from config. If Config is given, it will search given config (including mission config) for the loadout information. In either case, the config should contain the following entries, which is standard for any unit class, for example:
class MyLoadout
{
	uniformClass = "U_B_CombatUniform_mcam";
	backpack = "B_AssaultPack_mcamo";
	linkedItems[] = {"V_PlateCarrier1_rgr","H_HelmetB","ItemCompass","ItemWatch","ItemRadio","NVGoggles"};
	weapons[] = {"arifle_MX_ACO_pointer_F","hgun_P07_F"};
	items[] = {"FirstAidKit","FirstAidKit","FirstAidKit"};
	magazines[] = {"30Rnd_65x39_caseless_mag","16Rnd_9x21_Mag","SmokeShell","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade","HandGrenade"};
};
Groups:
Unit Inventory

Syntax 1

Syntax:
unit setUnitLoadout loadout
Parameters:
unit: Object
loadout: Array - Unit Loadout Array
Return Value:
Nothing

Syntax 2

Syntax:
unit setUnitLoadout [loadout, fullMagazines]
Parameters:
unit: Object
loadout: Array - Unit Loadout Array
fullMagazines: Boolean - partially emptied magazines will be refilled when the loadout is applied
Return Value:
Nothing

Syntax 3

Syntax:
unit setUnitLoadout name
Parameters:
unit: Object
name: String - class name (see description)
Return Value:
Nothing

Syntax 4

Syntax:
unit setUnitLoadout config
Parameters:
unit: Object
config: Config - config class (see description)
Return Value:
Nothing

Examples

Example 1:
player_2 setUnitLoadout (getUnitLoadout player_1); // Copies loadout from player_1 and applies it to player_2
Example 2:
player_2 setUnitLoadout [getUnitLoadout player_1, true]; // Copies loadout from player_1 and applies it to player_2 while topping up all magazines
Example 3:
_unit setUnitLoadout "B_Soldier_F";
Example 4:
_unit setUnitLoadout (configFile >> "CfgVehicles" >> "B_Soldier_F");
Example 5:
_unit setUnitLoadout (missionConfigFile >> "MyLoadout");
Example 6:
Strip unit of everything:
_unit setUnitLoadout (configFile >> "EmptyLoadout");

Additional Information

See also:
getUnitLoadout

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


Posted on 2019-12-17 - 23:08 (UTC)
demellion
NOTE: Empty or used magazines in loadouts will be refilled under specific circumstance, even if the refill argument is false. This seems to happen if amount of used magazines is 2 or more.
player setUnitLoadout [ ["arifle_MX_ACO_pointer_F","","acc_pointer_IR","optic_Aco",[],[],""], [], ["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""], ["U_B_CombatUniform_mcam",[["30Rnd_65x39_caseless_mag",1,1]]], ["V_PlateCarrier1_rgr",[]], ["B_AssaultPack_mcamo_Ammo",[]], "H_HelmetB_grass","",[],["ItemMap","","ItemRadio","ItemCompass","ItemWatch","NVGoggles"] ]
Will result in 30Rnd magazine with one bullet in it.
player setUnitLoadout [ ["arifle_MX_ACO_pointer_F","","acc_pointer_IR","optic_Aco",[],[],""], [], ["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""], ["U_B_CombatUniform_mcam",[["30Rnd_65x39_caseless_mag",2,1]]], ["V_PlateCarrier1_rgr",[]], ["B_AssaultPack_mcamo_Ammo",[]], "H_HelmetB_grass","",[],["ItemMap","","ItemRadio","ItemCompass","ItemWatch","NVGoggles"] ]
Will result in 2 magazines but full, 30 rounds in it. This applies to any magazines count >2. They will never be with specified amount of rounds, even if you force the refill argument to false
Posted on 2020-10-23 - 21:16 (UTC)
Andrew_S90
Here is a command I wrote up that provides a fix for the ammo bug described by demellion above. https://pastebin.com/SHX41Jkk Pass a loadout to your compiled command and it will provide one back that will not refill ammo
POLPOX - c
Posted on Aug 23, 2022 - 08:27 (UTC)
player setUnitLoadout [ nil, nil, nil, nil, nil, ["B_Bergen_sgg",nil], nil, nil, nil, nil ];
You can use nil to skip some desired parameter. The skipped part will be ignored and remain the same with old loadout.
This method is very slightly faster than the latter method:
private _loadout = getUnitLoadout player; _loadout#5 set [0,"B_Bergen_mcamo_F"]; player setUnitLoadout _loadout;