22#include " script_component.hpp"
33
44params [" " , " " , " _params" ];
5- _params params [" _player" , " _layout" , " _actionLabel" , " _config" ];
5+ _params params [" _player" , " _layout" , " _actionLabel" , " _config" , " " , " " , [ " _delay " , 2 ] ];
66
77private _callback = {
8- params [" _args" ];
9- _args params [" _player" , " _layout" , " " , " _config" , " _giveBack" , " _consume" ];
8+ params [" _args" ];
9+ _args params [" _player" , " _layout" , " " , " _config" , " _giveBack" , " _consume" ];
1010
11- private _insignia = [_player ] call BIS_fnc_getUnitInsignia ;
12- // setUnitLoadout will clear insignia, but BIS_fnc_setUnitInsignia does
13- // not known about this and would ignore the next call
14- [_player , " " ] call BIS_fnc_setUnitInsignia ;
11+ private _insignia = [_player ] call BIS_fnc_getUnitInsignia ;
12+ // setUnitLoadout will clear insignia, but BIS_fnc_setUnitInsignia does
13+ // not known about this and would ignore the next call
14+ [_player , " " ] call BIS_fnc_setUnitInsignia ;
1515
16- private _loadout = getUnitLoadout _player ;
16+ private _loadout = getUnitLoadout _player ;
1717
18- _layout params [" " , " _loadoutIndex" , " _loadoutSecondary" ];
18+ _layout params [" " , " _loadoutIndex" , " _loadoutSecondary" ];
1919
20- if ( _loadoutSecondary == - 1 ) then {
21- _loadout set [_loadoutIndex , _config ];
22- } else {
23- (_loadout select _loadoutIndex ) set [_loadoutSecondary , _config ];
24- };
20+ if ( _loadoutSecondary == - 1 ) then {
21+ _loadout set [_loadoutIndex , _config ];
22+ } else {
23+ (_loadout select _loadoutIndex ) set [_loadoutSecondary , _config ];
24+ };
2525
26- // setUnitLoadout causes NVGs to turn off.
27- // Let's figure out if the player was using NVGs and set the
28- // state again after setting the loadout.
29- private _nvgState = currentVisionMode _player ;
30-
31- // setUnitLoadout causes TFAR backpacks to lose settings.
32- // Before setting the player's loadout, let's grab their TFAR radio
33- // settings so we can copy the settings to the "new" radio bag.
34- // TFAR code snippets were adapted from TFAR_fnc_CopySettings.
35- private _playerBag = (_loadout select 5 ) select 0 ;
36- private _tfarSource = [];
37- private _lrSettingsSource = [];
38-
39- // Check if TFAR is active
40- private _tfarIsActive = isClass (configFile >> " CfgPatches" >> " tfar_core" );
41- if (_tfarIsActive ) then
26+ // setUnitLoadout causes NVGs to turn off.
27+ // Let's figure out if the player was using NVGs and set the
28+ // state again after setting the loadout.
29+ private _nvgState = currentVisionMode _player ;
30+
31+ // setUnitLoadout causes TFAR backpacks to lose settings.
32+ // Before setting the player's loadout, let's grab their TFAR radio
33+ // settings so we can copy the settings to the "new" radio bag.
34+ // TFAR code snippets were adapted from TFAR_fnc_CopySettings.
35+ private _playerBag = (_loadout select 5 ) select 0 ;
36+ private _tfarSource = [];
37+ private _lrSettingsSource = [];
38+
39+ // Check if TFAR is active
40+ private _tfarIsActive = isClass (configFile >> " CfgPatches" >> " tfar_core" );
41+ if (_tfarIsActive ) then
42+ {
43+ // Check if player has backpack and backpack is TFAR radio
44+ if ([_playerBag ] call TFAR_fnc_isLRRadio ) then
4245 {
43- // Check if player has backpack and backpack is TFAR radio
44- if ([_playerBag ] call TFAR_fnc_isLRRadio ) then
45- {
46- // Get player backpack radio and settigns
47- _tfarSource = _player call TFAR_fnc_backpackLr ;
48- _lrSettingsSource = _tfarSource call TFAR_fnc_getLrSettings ;
49- };
46+ // Get player backpack radio and settigns
47+ _tfarSource = _player call TFAR_fnc_backpackLr ;
48+ _lrSettingsSource = _tfarSource call TFAR_fnc_getLrSettings ;
5049 };
50+ };
5151
52- _player setUnitLoadout _loadout ;
52+ _player setUnitLoadout _loadout ;
5353
54- [_player ] call EFUNC(gearinfo,applyTextureOptions);
54+ [_player ] call EFUNC(gearinfo,applyTextureOptions);
5555
56- [_player , _insignia ] call BIS_fnc_setUnitInsignia ;
56+ [_player , _insignia ] call BIS_fnc_setUnitInsignia ;
5757
58- // Why would we make someone stand up?
59- // What if they are laying down to avoid fire?
60- /*
61- if ( currentWeapon _player != "" ) then {
62- _player playMoveNow "amovpercmstpslowwrfldnon";
63- };
64- */
58+ // Why would we make someone stand up?
59+ // What if they are laying down to avoid fire?
60+ /*
61+ if ( currentWeapon _player != "" ) then {
62+ _player playMoveNow "amovpercmstpslowwrfldnon";
63+ };
64+ */
6565
66- if ( _consume ! = " " ) then {
67- _player removeItem _consume ;
68- };
69- if ( _giveBack ! = " " ) then {
70- _player addItem _giveBack ;
71- };
66+ if ( _consume ! = " " ) then {
67+ _player removeItem _consume ;
68+ };
69+ if ( _giveBack ! = " " ) then {
70+ _player addItem _giveBack ;
71+ };
7272
73- // Check if TFAR is active
74- if (_tfarIsActive ) then
75- {
76- // Check if player has backpack and backpack is TFAR radio
77- private _newLoadout = getUnitLoadout _player ;
78- _playerBag = (_newLoadout select 5 ) select 0 ;
79-
80- if ([_playerBag ] call TFAR_fnc_isLRRadio ) then
81- {
82- // Get player backpack radio and set settings
83- private _tfarDestination = _player call TFAR_fnc_backpackLr ;
84- [_tfarDestination ,[]+ _lrSettingsSource ] call TFAR_fnc_setLRSettings ;
85- };
86- };
73+ // Check if TFAR is active
74+ if (_tfarIsActive ) then
75+ {
76+ // Check if player has backpack and backpack is TFAR radio
77+ private _newLoadout = getUnitLoadout _player ;
78+ _playerBag = (_newLoadout select 5 ) select 0 ;
8779
88- // Check if player has NVGs. If they do and they were using them, turn back on.
89- // We also need to make sure that whatever is in the NVG slot has NVG capabilities.
90- private _nvgItem = hmd _player ;
91- private _hasNVGs = (_nvgItem ! = " " );
92- private _canNVG = " NVG" in (getArray (configFile >> " CfgWeapons" >> _nvgItem >> " visionMode" ));
93- if (_hasNVGs && {_canNVG && {_nvgState > 0 }}) then
80+ if ([_playerBag ] call TFAR_fnc_isLRRadio ) then
9481 {
95- _player action [" nvGoggles" , _player ];
82+ // Get player backpack radio and set settings
83+ private _tfarDestination = _player call TFAR_fnc_backpackLr ;
84+ [_tfarDestination ,[]+ _lrSettingsSource ] call TFAR_fnc_setLRSettings ;
9685 };
86+ };
9787
88+ // Check if player has NVGs. If they do and they were using them, turn back on.
89+ // We also need to make sure that whatever is in the NVG slot has NVG capabilities.
90+ private _nvgItem = hmd _player ;
91+ private _hasNVGs = (_nvgItem ! = " " );
92+ private _canNVG = " NVG" in (getArray (configFile >> " CfgWeapons" >> _nvgItem >> " visionMode" ));
93+ if (_hasNVGs && {_canNVG && {_nvgState > 0 }}) then
94+ {
95+ _player action [" nvGoggles" , _player ];
9896 };
9997
98+ };
99+
100+ if ( _delay == 0 ) then {
101+ // Instant
102+ [_params ] call _callback ;
103+ }
104+ else {
100105 // ace_common_fnc_progressBar does not function while a player is in a vehicle.
101106 // To get around this, we will execute the progress bar only while on foot.
102107 // While in a vehicle, we will simply wait 2 seconds before swapping player items.
103108 private _isOnFoot = isNull objectParent _player ;
104109 if (_isOnFoot ) then
105110 {
106- [2 , _params , _callback , {}, _actionLabel + " ..." ] call ace_common_fnc_progressBar ;
111+ [_delay , _params , _callback , {}, _actionLabel + " ..." ] call ace_common_fnc_progressBar ;
107112 } else {
108113 [_params ,_callback ] spawn {
109114 params [" _params" ," _callback" ];
110- sleep 2 ;
115+ sleep _delay ;
111116 [_params ] call _callback ;
112117 };
113- };
118+ };
119+ };
0 commit comments