From 4169351b1ab2e1c8f2889e49054a568bdad37e25 Mon Sep 17 00:00:00 2001 From: commy2 Date: Thu, 16 Apr 2015 02:00:37 +0200 Subject: [PATCH] fix addActionEH didn't work after respawn --- addons/common/functions/fnc_addActionEventHandler.sqf | 8 ++++++-- addons/common/functions/fnc_removeActionEventHandler.sqf | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/addons/common/functions/fnc_addActionEventHandler.sqf b/addons/common/functions/fnc_addActionEventHandler.sqf index a75b1537d1..a0e9d24f2c 100644 --- a/addons/common/functions/fnc_addActionEventHandler.sqf +++ b/addons/common/functions/fnc_addActionEventHandler.sqf @@ -31,7 +31,11 @@ if (typeName _statement == "STRING") then { _name = format ["ACE_Action_%1", _action]; -_actionsVar = _unit getVariable [_name, [-1, [-1, [], []]]]; +_actionsVar = _unit getVariable [_name, [-1, [-1, [], []], objNull]]; + +if (_unit != _actionsVar select 2) then { // check if the unit is still valid, fixes respawn issues + _actionsVar = [-1, [-1, [], []], objNull]; +}; _actionID = _actionsVar select 0; _actions = _actionsVar select 1; @@ -65,6 +69,6 @@ if (_actionID == -1) then { _actionID = _unit addAction _addAction; }; -_unit setVariable [_name, [_actionID, [_id, _actionIDs, _actions]], false]; +_unit setVariable [_name, [_actionID, [_id, _actionIDs, _actions], _unit], false]; _id diff --git a/addons/common/functions/fnc_removeActionEventHandler.sqf b/addons/common/functions/fnc_removeActionEventHandler.sqf index 7d92b3de75..2bcc970ab0 100644 --- a/addons/common/functions/fnc_removeActionEventHandler.sqf +++ b/addons/common/functions/fnc_removeActionEventHandler.sqf @@ -23,7 +23,7 @@ if (_id == -1) exitWith {}; _name = format ["ACE_Action_%1", _action]; -_actionsVar = _unit getVariable [_name, [-1, [-1, [], []]]]; +_actionsVar = _unit getVariable [_name, [-1, [-1, [], []], objNull]]; _actionID = _actionsVar select 0; _actions = _actionsVar select 1; @@ -32,6 +32,8 @@ _currentID = _actions select 0; _actionIDs = _actions select 1; _actions = _actions select 2; +if (_unit != _actionsVar select 2) exitWith {}; + _id = _actionIDs find _id; if (_id == -1) exitWith {}; @@ -47,4 +49,4 @@ if (count _actions == 0) then { _actionID = -1; }; -_unit setVariable [_name, [_actionID, [_currentID, _actionIDs, _actions]], false]; +_unit setVariable [_name, [_actionID, [_currentID, _actionIDs, _actions], _unit], false];