@@ -38,25 +38,30 @@ if ([_vehicle] call FUNC(areVehicleRacksInitialized)) exitWith {
38
38
false
39
39
};
40
40
41
- // A player must do the action of initialising a rack
42
- private _player = objNull ;
43
-
44
- private _vehiclePresetName = [_vehicle ] call FUNC(getVehicleRacksPreset);
45
- if (_condition isEqualTo {} && {_vehiclePresetName isNotEqualTo " " }) then {
46
- _player = ([] call CBA_fnc_players ) select 0 ;
47
- } else {
48
- private _players = [] call CBA_fnc_players ;
49
- private _index = _players findIf {[_x ] call _condition };
50
-
51
- if (_index == - 1 ) then {
52
- WARNING_1(" No unit found for condition %1 - defaulting to first player" ,_condition );
53
- _index = 0 ;
41
+ // Exec the rest on the next frame, to prevent issues if the function is called in a 3DEN init box
42
+ [{
43
+ params [" _vehicle" , " _condition" ];
44
+
45
+ // A player must do the action of initialising a rack
46
+ private _player = objNull ;
47
+
48
+ private _vehiclePresetName = [_vehicle ] call FUNC(getVehicleRacksPreset);
49
+ if (_condition isEqualTo {} && {_vehiclePresetName isNotEqualTo " " }) then {
50
+ _player = ([] call CBA_fnc_players ) select 0 ;
51
+ } else {
52
+ private _players = [] call CBA_fnc_players ;
53
+ private _index = _players findIf {[_x ] call _condition };
54
+
55
+ if (_index == - 1 ) then {
56
+ WARNING_1(" No unit found for condition %1 - defaulting to first player" ,_condition );
57
+ _index = 0 ;
58
+ };
59
+ _player = _players select _index ;
54
60
};
55
- _player = _players select _index ;
56
- };
57
61
58
- _vehicle setVariable [QEGVAR(sys_rack,initPlayer), _player , true ];
62
+ _vehicle setVariable [QEGVAR(sys_rack,initPlayer), _player , true ];
59
63
60
- [QEGVAR(sys_rack,initVehicleRacks), [_vehicle ], _player ] call CBA_fnc_targetEvent ;
64
+ [QEGVAR(sys_rack,initVehicleRacks), [_vehicle ], _player ] call CBA_fnc_targetEvent ;
65
+ }, [_vehicle , _condition ]] call CBA_fnc_execNextFrame ;
61
66
62
67
true
0 commit comments