Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map - Use SlotItemChanged event #9961

Merged
merged 6 commits into from
Oct 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions addons/map/XEH_postInitClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
_oldPlayer removeEventHandler ["SlotItemChanged", _ehID];

_oldPlayer setVariable [QGVAR(ehID), nil];
};

if (isNull _newPlayer) exitWith {
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
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;


Expand Down