From 08e6d50db0c34ccf24172ed0ff3f0db05e2e7aaf Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sat, 20 Apr 2024 16:23:16 +0200 Subject: [PATCH 1/3] Update XEH_postInitClient.sqf --- addons/map/XEH_postInitClient.sqf | 35 ++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/addons/map/XEH_postInitClient.sqf b/addons/map/XEH_postInitClient.sqf index ea3ce194647..5b0f14b20e8 100644 --- a/addons/map/XEH_postInitClient.sqf +++ b/addons/map/XEH_postInitClient.sqf @@ -65,15 +65,36 @@ GVAR(flashlights) = [] call CBA_fnc_createNamespace; // hide clock on map if player has no watch GVAR(hasWatch) = true; -["loadout", { - params ["_unit"]; - if (isNull _unit) exitWith { +["unit", { + params ["_newPlayer", "_oldPlayer"]; + + private _ehID = _oldPlayer getVariable QGVAR(ehID); + + if (!isNil "_ehID") then { + _oldPlayer removeEventHandler ["SlotItemChanged", _ehID]; + + _oldPlayer setVariable [QGVAR(ehID), nil]; + }; + + if (isNull _newPlayer) exitWith { GVAR(hasWatch) = true; }; - GVAR(hasWatch) = false; - { - if (_x isKindOf ["ItemWatch", configFile >> "CfgWeapons"]) exitWith {GVAR(hasWatch) = true;}; - } forEach (assignedItems _unit); + + _ehID = _newPlayer getVariable QGVAR(ehID); + + if (isNil "_ehID") then { + _ehID = _newPlayer addEventHandler ["SlotItemChanged", { + params ["", "_item", "_slot", "_assign"]; + + if (_slot != TYPE_WATCH) exitWith {}; + + GVAR(hasWatch) = _assign && {_item isKindOf ["ItemWatch", configFile >> "CfgWeapons"]}; + }]; + + _newPlayer setVariable [QGVAR(ehID), _ehID]; + + GVAR(hasWatch) = (_newPlayer getSlotItemName TYPE_WATCH) isKindOf ["ItemWatch", configFile >> "CfgWeapons"]; + }; }, true] call CBA_fnc_addPlayerEventHandler; From 58cea6b7e13613fdd3175c132a36c874ef19e9c7 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Fri, 14 Jun 2024 20:52:15 +0200 Subject: [PATCH 2/3] Use `addPlayerEH` --- addons/map/XEH_postInitClient.sqf | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/addons/map/XEH_postInitClient.sqf b/addons/map/XEH_postInitClient.sqf index 4649d704a80..717d6756183 100644 --- a/addons/map/XEH_postInitClient.sqf +++ b/addons/map/XEH_postInitClient.sqf @@ -65,36 +65,22 @@ GVAR(flashlights) = createHashMap; // hide clock on map if player has no watch GVAR(hasWatch) = true; -["unit", { - params ["_newPlayer", "_oldPlayer"]; +[QGVAR(slotItemChanged), "SlotItemChanged", { + params ["", "_item", "_slot", "_assign"]; - private _ehID = _oldPlayer getVariable QGVAR(ehID); + if (_slot != TYPE_WATCH) exitWith {}; - if (!isNil "_ehID") then { - _oldPlayer removeEventHandler ["SlotItemChanged", _ehID]; + GVAR(hasWatch) = _assign && {_item isKindOf ["ItemWatch", configFile >> "CfgWeapons"]}; +}] call EFUNC(common,addPlayerEH); - _oldPlayer setVariable [QGVAR(ehID), nil]; - }; +["unit", { + params ["_newPlayer"]; if (isNull _newPlayer) exitWith { GVAR(hasWatch) = true; }; - _ehID = _newPlayer getVariable QGVAR(ehID); - - if (isNil "_ehID") then { - _ehID = _newPlayer addEventHandler ["SlotItemChanged", { - params ["", "_item", "_slot", "_assign"]; - - if (_slot != TYPE_WATCH) exitWith {}; - - GVAR(hasWatch) = _assign && {_item isKindOf ["ItemWatch", configFile >> "CfgWeapons"]}; - }]; - - _newPlayer setVariable [QGVAR(ehID), _ehID]; - - GVAR(hasWatch) = (_newPlayer getSlotItemName TYPE_WATCH) isKindOf ["ItemWatch", configFile >> "CfgWeapons"]; - }; + GVAR(hasWatch) = (_newPlayer getSlotItemName TYPE_WATCH) isKindOf ["ItemWatch", configFile >> "CfgWeapons"]; }, true] call CBA_fnc_addPlayerEventHandler; From c39c38261d3628565a078bbb819bc04322538df1 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 8 Oct 2024 10:57:14 -0500 Subject: [PATCH 3/3] Switch to `CBA_fnc_addBISPlayerEventHandler` --- addons/map/XEH_postInitClient.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/map/XEH_postInitClient.sqf b/addons/map/XEH_postInitClient.sqf index d116bf04f75..d04ddc738af 100644 --- a/addons/map/XEH_postInitClient.sqf +++ b/addons/map/XEH_postInitClient.sqf @@ -71,7 +71,7 @@ GVAR(hasWatch) = true; if (_slot != TYPE_WATCH) exitWith {}; GVAR(hasWatch) = _assign && {_item isKindOf ["ItemWatch", configFile >> "CfgWeapons"]}; -}] call EFUNC(common,addPlayerEH); +}] call CBA_fnc_addBISPlayerEventHandler; ["unit", { params ["_newPlayer"];