fix addActionEH didn't work after respawn

This commit is contained in:
commy2 2015-04-16 02:00:37 +02:00
parent 8aeeff616e
commit 4169351b1a
2 changed files with 10 additions and 4 deletions

View File

@ -31,7 +31,11 @@ if (typeName _statement == "STRING") then {
_name = format ["ACE_Action_%1", _action]; _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; _actionID = _actionsVar select 0;
_actions = _actionsVar select 1; _actions = _actionsVar select 1;
@ -65,6 +69,6 @@ if (_actionID == -1) then {
_actionID = _unit addAction _addAction; _actionID = _unit addAction _addAction;
}; };
_unit setVariable [_name, [_actionID, [_id, _actionIDs, _actions]], false]; _unit setVariable [_name, [_actionID, [_id, _actionIDs, _actions], _unit], false];
_id _id

View File

@ -23,7 +23,7 @@ if (_id == -1) exitWith {};
_name = format ["ACE_Action_%1", _action]; _name = format ["ACE_Action_%1", _action];
_actionsVar = _unit getVariable [_name, [-1, [-1, [], []]]]; _actionsVar = _unit getVariable [_name, [-1, [-1, [], []], objNull]];
_actionID = _actionsVar select 0; _actionID = _actionsVar select 0;
_actions = _actionsVar select 1; _actions = _actionsVar select 1;
@ -32,6 +32,8 @@ _currentID = _actions select 0;
_actionIDs = _actions select 1; _actionIDs = _actions select 1;
_actions = _actions select 2; _actions = _actions select 2;
if (_unit != _actionsVar select 2) exitWith {};
_id = _actionIDs find _id; _id = _actionIDs find _id;
if (_id == -1) exitWith {}; if (_id == -1) exitWith {};
@ -47,4 +49,4 @@ if (count _actions == 0) then {
_actionID = -1; _actionID = -1;
}; };
_unit setVariable [_name, [_actionID, [_currentID, _actionIDs, _actions]], false]; _unit setVariable [_name, [_actionID, [_currentID, _actionIDs, _actions], _unit], false];