mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Adding hideUnit functions to ace_common
This commit is contained in:
parent
13f5b08892
commit
d036639b46
@ -6,7 +6,7 @@
|
||||
//Singe PFEH to handle execNextFrame and waitAndExec:
|
||||
[{
|
||||
private ["_entry"];
|
||||
|
||||
|
||||
//Handle the waitAndExec array:
|
||||
while {((count GVAR(waitAndExecArray)) > 0) && {((GVAR(waitAndExecArray) select 0) select 0) <= ACE_Time}} do {
|
||||
_entry = GVAR(waitAndExecArray) deleteAt 0;
|
||||
@ -56,6 +56,10 @@
|
||||
["setFuel", {(_this select 0) setFuel (_this select 1)}] call FUNC(addEventhandler);
|
||||
["setSpeaker", {(_this select 0) setSpeaker (_this select 1)}] call FUNC(addEventhandler);
|
||||
|
||||
if (isServer) then {
|
||||
["hideObjectGlobal", {(_this select 0) hideObjectGlobal (_this select 1)}] call FUNC(addEventHandler);
|
||||
};
|
||||
|
||||
// hack to get PFH to work in briefing
|
||||
[QGVAR(onBriefingPFH), "onEachFrame", {
|
||||
if (ACE_time > 0) exitWith {
|
||||
|
@ -102,6 +102,7 @@ PREP(goKneeling);
|
||||
PREP(hadamardProduct);
|
||||
PREP(hasItem);
|
||||
PREP(hasMagazine);
|
||||
PREP(hideUnit);
|
||||
PREP(inheritsFrom);
|
||||
PREP(insertionSort);
|
||||
PREP(interpolateFromArray);
|
||||
@ -179,6 +180,7 @@ PREP(toBin);
|
||||
PREP(toBitmask);
|
||||
PREP(toHex);
|
||||
PREP(toNumber);
|
||||
PREP(unhideUnit);
|
||||
PREP(uniqueElementsOnly);
|
||||
PREP(unloadPerson);
|
||||
PREP(unloadPersonLocal);
|
||||
|
34
addons/common/functions/fnc_hideUnit.sqf
Normal file
34
addons/common/functions/fnc_hideUnit.sqf
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Author: SilentSpike (based on muteUnit)
|
||||
* Globally hides a unit. This allows the handling of more than one reason to hide an object globally.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Reason to hide the unit <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* nil
|
||||
*
|
||||
* Example:
|
||||
* [ACE_Player, "SpectatorMode"] call ace_common_fnc_hideUnit
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_reason);
|
||||
|
||||
if (isNull _unit) exitWith {};
|
||||
|
||||
private "_setHiddenReasons";
|
||||
_setHiddenReasons = _unit getVariable [QGVAR(setHiddenReasons), []];
|
||||
|
||||
if !(_reason in _setHiddenReasons) then {
|
||||
_setHiddenReasons pushBack _reason;
|
||||
_unit setVariable [QGVAR(setHiddenReasons), _setHiddenReasons, true];
|
||||
};
|
||||
|
||||
if !(isObjectHidden _unit) then {
|
||||
["hideObjectGlobal",[_unit,true]] call FUNC(serverEvent);
|
||||
};
|
34
addons/common/functions/fnc_unhideUnit.sqf
Normal file
34
addons/common/functions/fnc_unhideUnit.sqf
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Author: SilentSpike (based on unmuteUnit)
|
||||
* Globally unhides a unit. Only unhides if the last reason was removed.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Reason to unhide the unit <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* nil
|
||||
*
|
||||
* Example:
|
||||
* [ACE_Player, "SpectatorMode"] call ace_common_fnc_unhideUnit
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_reason);
|
||||
|
||||
if (isNull _unit) exitWith {};
|
||||
|
||||
private "_setHiddenReasons";
|
||||
_setHiddenReasons = _unit getVariable [QGVAR(setHiddenReasons), []];
|
||||
|
||||
if (_reason in _setHiddenReasons) then {
|
||||
_setHiddenReasons deleteAt (_setHiddenReasons find _reason);
|
||||
_unit setVariable [QGVAR(setHiddenReasons), _setHiddenReasons, true];
|
||||
};
|
||||
|
||||
if (_setHiddenReasons isEqualTo []) then {
|
||||
["hideObjectGlobal",[_unit,false]] call FUNC(serverEvent);
|
||||
};
|
Loading…
Reference in New Issue
Block a user