ACE3/addons/spectator/functions/fnc_setSpectator.sqf

45 lines
1.2 KiB
Plaintext
Raw Normal View History

/*
* Author: SilentSpike
* Sets target unit to the given spectator state (virtually)
* To physically handle a spectator see ace_spectator_fnc_stageSpectator
*
* Units will be able to communicate in ACRE/TFAR as appropriate
* The spectator interface will be opened/closed
*
* Arguments:
* 0: Unit to put into spectator state <OBJECT>
* 1: Spectator state <BOOL> <OPTIONAL>
*
* Return Value:
2015-07-04 23:49:47 +00:00
* None <NIL>
*
* Example:
* [player, true] call ace_spectator_fnc_setSpectator
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_unit", ["_set",true,[true]]];
// Only run for player units
if !(isPlayer _unit) exitWith {};
if !(local _unit) exitwith {
[[_unit, _set, _target], QFUNC(setSpectator), _unit] call EFUNC(common,execRemoteFnc);
};
if (_set) then {
2015-07-15 11:03:54 +00:00
["open"] call FUNC(handleInterface);
} else {
2015-07-15 11:03:54 +00:00
["close"] call FUNC(handleInterface);
};
// Handle common addon audio
if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableVolumeUpdate) = _set};
if (["acre_sys_radio"] call EFUNC(common,isModLoaded)) then {[_set] call acre_api_fnc_setSpectator};
if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[_unit, _set] call TFAR_fnc_forceSpectator};
["spectatorSet",[_set]] call EFUNC(common,localEvent);