From 788c23c94025938389ab42e3f360b1e25b2989a3 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sun, 5 Jul 2015 21:30:19 +0100 Subject: [PATCH] Allow resetting existing spectators --- addons/spectator/functions/fnc_setSpectator.sqf | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index 83f0c8aeb8..070994013f 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -21,7 +21,8 @@ _unit = player; _target = _this select 0; _set = if (count _this > 1) then {_this select 1} else {true}; -if (_set isEqualTo (_unit getVariable [QGVAR(isSpectator), false])) exitWith {}; +// No change, no service (but allow spectators who respawn to be reset) +if !(_set || (_unit getVariable [QGVAR(isSpectator), false])) exitWith {}; // Prevent player falling into water _unit enableSimulation !_set; @@ -67,7 +68,10 @@ if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[_unit, _set] cal _unit allowDamage !_set; _unit setVariable [QEGVAR(medical,allowDamage), !_set]; -// Mark spectator state for external reference -_unit setVariable [QGVAR(isSpectator), _set]; +// No theoretical change if an existing spectator was reset +if !(_set && (_unit getVariable [QGVAR(isSpectator), false])) then { + // Mark spectator state for reference + _unit setVariable [QGVAR(isSpectator), _set]; -["spectatorChanged",[_set]] call EFUNC(common,localEvent); + ["spectatorChanged",[_set]] call EFUNC(common,localEvent); +};