added PM's solution

This commit is contained in:
bux578 2015-02-10 18:57:23 +01:00
parent e14d49393a
commit 40e422f95a
5 changed files with 44 additions and 39 deletions

View File

@ -3,10 +3,10 @@ class Extended_PreInit_EventHandlers {
init = QUOTE( call COMPILE_FILE(XEH_preInit) );
};
};
/*
class Extended_PostInit_EventHandlers {
class ADDON {
clientInit = QUOTE( call COMPILE_FILE(XEH_clientInit) );
};
};
*/

View File

@ -16,28 +16,13 @@
#include "script_component.hpp"
/*
DFUNC(pfhClientInit) = {
if (GVAR(EnableSwitchUnits)) exitWith {
private ["_sides"];
_sides = [];
if(GVAR(SwitchToWest)) then {_sides pushBack west;};
if(GVAR(SwitchToEast)) then {_sides pushBack east;};
if(GVAR(SwitchToIndependent)) then {_sides pushBack independent;};
if(GVAR(SwitchToCivilian)) then {_sides pushBack civilian;};
if (player getVariable ["ACE_CanSwitchUnits", false]) then {
[player, _sides] call FUNC(initPlayer);
if (missionNamespace getVariable [QGVAR(EnableSwitchUnits), false]) then {
[player] call FUNC(startSwitchUnits);
} else {
["SettingChanged", {
PARAMS_2(_name,_value);
if ((_name == QGVAR(EnableSwitchUnits)) && {_value}) then {
[player] call FUNC(startSwitchUnits);
};
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
}] call FUNC(addEventhandler);
};
[FUNC(pfhClientInit), 0.5, []] call cba_fnc_addPerFrameHandler;
*/

View File

@ -9,6 +9,7 @@ PREP(isValidAi);
PREP(markAiOnMap);
PREP(module);
PREP(nearestPlayers);
PREP(startSwitchUnits);
PREP(switchBack);
PREP(switchUnit);

View File

@ -37,17 +37,3 @@ GVAR(Module) = true;
[QGVAR(EnableSwitchUnits), true, false, true] call EFUNC(common,setSetting);
diag_log text "[ACE]: SwitchUnits Module Initialized.";
if (GVAR(EnableSwitchUnits)) then {
private ["_sides"];
_sides = [];
if(GVAR(SwitchToWest)) then {_sides pushBack west;};
if(GVAR(SwitchToEast)) then {_sides pushBack east;};
if(GVAR(SwitchToIndependent)) then {_sides pushBack independent;};
if(GVAR(SwitchToCivilian)) then {_sides pushBack civilian;};
if (player getVariable ["ACE_CanSwitchUnits", false]) then {
[player, _sides] call FUNC(initPlayer);
};
};

View File

@ -0,0 +1,33 @@
/*
* Author: bux578
* Starts the SwitchUnits functionality
*
* Arguments:
* 0: player <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_player] call FUNC(startSwitchUnits)
*
* Public: No
*/
#include "script_component.hpp"
EXPLODE_1_PVT[_this,_player];
if (GVAR(EnableSwitchUnits)) then {
private ["_sides"];
_sides = [];
if(GVAR(SwitchToWest)) then {_sides pushBack west;};
if(GVAR(SwitchToEast)) then {_sides pushBack east;};
if(GVAR(SwitchToIndependent)) then {_sides pushBack independent;};
if(GVAR(SwitchToCivilian)) then {_sides pushBack civilian;};
if (_player getVariable ["ACE_CanSwitchUnits", false]) then {
[_player, _sides] call FUNC(initPlayer);
};
};