From 509bfefff10d0547df6a6c64afc094c96aa1bb73 Mon Sep 17 00:00:00 2001 From: bux578 Date: Tue, 3 Feb 2015 21:47:48 +0100 Subject: [PATCH] fixed SwitchUnits needed to wait in initPlayer --- addons/switchunits/XEH_clientInit.sqf | 29 +++++++++----- .../switchunits/functions/fnc_initPlayer.sqf | 38 +++++++++---------- .../switchunits/functions/fnc_markAiOnMap.sqf | 6 ++- addons/switchunits/functions/fnc_module.sqf | 4 +- 4 files changed, 44 insertions(+), 33 deletions(-) diff --git a/addons/switchunits/XEH_clientInit.sqf b/addons/switchunits/XEH_clientInit.sqf index dbc239d119..3075d67941 100644 --- a/addons/switchunits/XEH_clientInit.sqf +++ b/addons/switchunits/XEH_clientInit.sqf @@ -16,15 +16,24 @@ #include "script_component.hpp" -private "_sides"; +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;}; -_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 (player getVariable ["ACE_CanSwitchUnits", false]) then { + [player, _sides] call FUNC(initPlayer); + }; + + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; }; + +[FUNC(pfhClientInit), 0.5, []] call cba_fnc_addPerFrameHandler; diff --git a/addons/switchunits/functions/fnc_initPlayer.sqf b/addons/switchunits/functions/fnc_initPlayer.sqf index c4e2d19747..9c71f8cefc 100644 --- a/addons/switchunits/functions/fnc_initPlayer.sqf +++ b/addons/switchunits/functions/fnc_initPlayer.sqf @@ -24,28 +24,28 @@ _sides = _this select 1; if (vehicle _playerUnit == _playerUnit) then { - [_sides] call FUNC(markAiOnMap); + [_sides] call FUNC(markAiOnMap); - _playerUnit setVariable [QGVAR(IsPlayerUnit), true]; - _playerUnit allowDamage false; + _playerUnit setVariable [QGVAR(IsPlayerUnit), true]; + _playerUnit allowDamage false; - GVAR(OriginalUnit) = _playerUnit; - //GVAR(OriginalName) = [_playerUnit] call EFUNC(common,getName); - GVAR(OriginalName) = name _playerUnit; - GVAR(OriginalGroup) = group _playerUnit; + GVAR(OriginalUnit) = _playerUnit; + //GVAR(OriginalName) = [_playerUnit] call EFUNC(common,getName); + GVAR(OriginalName) = name _playerUnit; + GVAR(OriginalGroup) = group _playerUnit; - // remove all starting gear of a player - removeAllWeapons _playerUnit; - removeGoggles _playerUnit; - removeHeadgear _playerUnit; - removeVest _playerUnit; - removeAllAssignedItems _playerUnit; - clearAllItemsFromBackpack _playerUnit; - removeBackpack _playerUnit; - _playerUnit linkItem "ItemMap"; - removeUniform _playerUnit; + // remove all starting gear of a player + removeAllWeapons _playerUnit; + removeGoggles _playerUnit; + removeHeadgear _playerUnit; + removeVest _playerUnit; + removeAllAssignedItems _playerUnit; + clearAllItemsFromBackpack _playerUnit; + removeBackpack _playerUnit; + _playerUnit linkItem "ItemMap"; + removeUniform _playerUnit; - [_playerUnit, "ACE_SwitchUnits", true] call EFUNC(common,setForceWalkStatus); + [_playerUnit, "ACE_SwitchUnits", true] call EFUNC(common,setForceWalkStatus); - [_playerUnit, _sides] call FUNC(addMapFunction); + [_playerUnit, _sides] call FUNC(addMapFunction); }; diff --git a/addons/switchunits/functions/fnc_markAiOnMap.sqf b/addons/switchunits/functions/fnc_markAiOnMap.sqf index ce7b575398..ed94c31b0b 100644 --- a/addons/switchunits/functions/fnc_markAiOnMap.sqf +++ b/addons/switchunits/functions/fnc_markAiOnMap.sqf @@ -10,7 +10,7 @@ * None * * Example: - * [west, east] call FUNC(markAiOnMap) + * [[west, east]] call FUNC(markAiOnMap) * * Public: No */ @@ -34,11 +34,13 @@ DFUNC(pfhMarkAiOnMap) = { } forEach GVAR(AllMarkerNames); if (alive ACE_player && {GVAR(OriginalUnit) getVariable ["ACE_CanSwitchUnits", false]}) then { - + // create markers { if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then { private ["_markerName", "_marker", "_markerColor"]; + + hint format ["marker. %1", time]; //_markerName = format ["%1", [_x] call EFUNC(common,getName)]; _markerName = str _x; diff --git a/addons/switchunits/functions/fnc_module.sqf b/addons/switchunits/functions/fnc_module.sqf index 9444cb5f61..0a06f737a5 100644 --- a/addons/switchunits/functions/fnc_module.sqf +++ b/addons/switchunits/functions/fnc_module.sqf @@ -27,8 +27,6 @@ if !(_activated) exitWith {}; GVAR(Module) = true; -[QGVAR(EnableSwitchUnits), true] call EFUNC(common,setParameter); - [_logic, QGVAR(SwitchToWest), "SwitchToWest"] call EFUNC(common,readBooleanParameterFromModule); [_logic, QGVAR(SwitchToEast), "SwitchToEast"] call EFUNC(common,readBooleanParameterFromModule); [_logic, QGVAR(SwitchToIndependent), "SwitchToIndependent"] call EFUNC(common,readBooleanParameterFromModule); @@ -37,4 +35,6 @@ GVAR(Module) = true; [_logic, QGVAR(EnableSafeZone), "EnableSafeZone"] call EFUNC(common,readBooleanParameterFromModule); [_logic, QGVAR(SafeZoneRadius), "SafeZoneRadius"] call EFUNC(common,readNumericParameterFromModule); +[QGVAR(EnableSwitchUnits), true] call EFUNC(common,setParameter); + diag_log text "[ACE]: SwitchUnits Module Initialized.";