From 0beaa40fbcd1f55209175501b3d9e382166cd755 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sun, 4 Oct 2015 13:52:54 +0100 Subject: [PATCH] Add API parameter to allow for unforced spectator Adds an optional boolean paremeter to the setSpectator function for forcing the interface. It is forced by default, so if `false` is passed as the value the spectator will be able to close the interface with the escape button. --- addons/spectator/functions/fnc_setSpectator.sqf | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index efa7000b8f..66344e69c6 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -7,7 +7,8 @@ * The spectator interface will be opened/closed * * Arguments: - * 0: Spectator state of local client + * 0: Spectator state of local client (default: true) + * 1: Force interface (default: true) * * Return Value: * None @@ -20,7 +21,7 @@ #include "script_component.hpp" -params [["_set",true,[true]]]; +params [["_set",true,[true]], ["_force",true,[true]]]; // Only clients can be spectators if (!hasInterface) exitWith {}; @@ -75,7 +76,17 @@ if (_set) then { [{ // Create the display (findDisplay 46) createDisplay QGVAR(interface); - }, []] call EFUNC(common,execNextFrame); + + // If not forced, make esc end spectator + if (_this) then { + (findDisplay 12249) displayAddEventHandler ["KeyDown", { + if (_this select 1 == 1) then { + [false] call ace_spectator_fnc_setSpectator; + true + }; + }]; + }; + }, !_force] call EFUNC(common,execNextFrame); // Cache and disable nametag settings if (["ace_nametags"] call EFUNC(common,isModLoaded)) then {