From decf1ecffa8a0767269bc5459ff278916f06ae66 Mon Sep 17 00:00:00 2001 From: mharis001 Date: Fri, 15 Nov 2019 17:19:28 -0500 Subject: [PATCH] Fix JIP event removal on non-server --- addons/events/XEH_preInit.sqf | 2 ++ addons/events/fnc_removeGlobalEventJIP.sqf | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/events/XEH_preInit.sqf b/addons/events/XEH_preInit.sqf index 5e480a37b..b8a2b27c1 100644 --- a/addons/events/XEH_preInit.sqf +++ b/addons/events/XEH_preInit.sqf @@ -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 diff --git a/addons/events/fnc_removeGlobalEventJIP.sqf b/addons/events/fnc_removeGlobalEventJIP.sqf index 60f99bdaa..5b4002c82 100644 --- a/addons/events/fnc_removeGlobalEventJIP.sqf +++ b/addons/events/fnc_removeGlobalEventJIP.sqf @@ -7,7 +7,7 @@ Description: Parameters: _jipID - A unique ID from CBA_fnc_globalEventJIP. - _object - Will remove jip EH when object is deleted or immediately if omitted [optional] + _object - Will remove JIP EH when object is deleted or immediately if omitted. (optional, default: objNull) Returns: Nothing @@ -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; };