Skip to content

Commit

Permalink
Merge pull request #1253 from mharis001/fix-jip-event-remove
Browse files Browse the repository at this point in the history
Fix JIP event removal on dedicated client
  • Loading branch information
commy2 committed Nov 16, 2019
2 parents 70563e9 + decf1ec commit 34cbd23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions addons/events/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ GVAR(eventHashes) = call CBA_fnc_createNamespace;
if (isServer) then {
GVAR(eventNamespaceJIP) = true call CBA_fnc_createNamespace;
publicVariable QGVAR(eventNamespaceJIP);

[QGVAR(removeGlobalEventJIP), CBA_fnc_removeGlobalEventJIP] call CBA_fnc_addEventHandler;
};

// can't add at preInit
Expand Down
16 changes: 10 additions & 6 deletions addons/events/fnc_removeGlobalEventJIP.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description:
Parameters:
_jipID - A unique ID from CBA_fnc_globalEventJIP. <STRING>
_object - Will remove jip EH when object is deleted or immediately if omitted [optional] <OBJECT>
_object - Will remove JIP EH when object is deleted or immediately if omitted. (optional, default: objNull) <OBJECT>
Returns:
Nothing
Expand All @@ -19,10 +19,14 @@ SCRIPT(removeGlobalEventJIP);

params [["_jipID", "", [""]], ["_object", objNull, [objNull]]];

if (isNull _object) then {
GVAR(eventNamespaceJIP) setVariable [_jipID, nil, true];
if (isServer) then {
if (isNull _object) then {
GVAR(eventNamespaceJIP) setVariable [_jipID, nil, true];
} else {
[_object, "Deleted", {
GVAR(eventNamespaceJIP) setVariable [_thisArgs, nil, true];
}, _jipID] call CBA_fnc_addBISEventHandler;
};
} else {
[_object, "Deleted", {
GVAR(eventNamespaceJIP) setVariable [_thisArgs, nil, true];
}, _jipID] call CBA_fnc_addBISEventHandler;
[QGVAR(removeGlobalEventJIP), [_jipID, _object]] call CBA_fnc_serverEvent;
};

0 comments on commit 34cbd23

Please sign in to comment.