Run on ACE_player instead of all units

This commit is contained in:
johnb432 2024-03-12 23:09:44 +01:00
parent ec17efe6f9
commit ab9c1c15eb
2 changed files with 25 additions and 3 deletions

View File

@ -32,7 +32,28 @@ GVAR(isUsingMagnification) = false;
["turret", LINKFUNC(refreshGoggleType), true] call CBA_fnc_addPlayerEventHandler;
["ACE_controlledUAV", LINKFUNC(refreshGoggleType)] call CBA_fnc_addEventHandler;
["CAManBase", "SlotItemChanged", LINKFUNC(onSlotItemChanged)] call CBA_fnc_addClassEventHandler;
["unit", {
params ["_newPlayer", "_oldPlayer"];
private _ehID = _oldPlayer getVariable QGVAR(ehID);
if (!isNil "_ehID") then {
_oldPlayer removeEventHandler ["SlotItemChanged", _ehID];
_oldPlayer setVariable [QGVAR(ehID), nil];
};
_ehID = _newPlayer getVariable QGVAR(ehID);
if (isNil "_ehID") then {
// Call manually to update existing value
[] call FUNC(refreshGoggleType);
_ehID = _newPlayer addEventHandler ["SlotItemChanged", LINKFUNC(onSlotItemChanged)];
_newPlayer setVariable [QGVAR(ehID), _ehID];
};
}, true] call CBA_fnc_addPlayerEventHandler;
// handle only brightness if effects are disabled
GVAR(ppEffectNVGBrightness) = ppEffectCreate ["ColorCorrections", 1236];

View File

@ -19,9 +19,10 @@
*/
params ["_unit", "_item", "_slot", "_assign"];
TRACE_4("onSlotItemChange",_unit,_item,_slot,_assign);
TRACE_4("onSlotItemChanged",_unit,_item,_slot,_assign);
if (_slot != TYPE_HMD) exitWith {};
if (_unit != ACE_player || _slot != TYPE_HMD) exitWith {};
if (!_assign) exitWith {
GVAR(playerHMD) = "";
};