forked from IDI-Systems/acre2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnc_handleBroadcasting.sqf
50 lines (45 loc) · 1.62 KB
/
fnc_handleBroadcasting.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "script_component.hpp"
/*
* Author: ACRE2Team
* Handles a unit broadcasting a message through all intercom stations.
*
* Arguments:
* 0: Vehicle with intercom <OBJECT>
* 1: Unit broadcasting <OBJECT>
* 2: Intercom network <NUMBER>
* 3: Is broadcasting <BOOL>
*
* Return Value:
* None
*
* Example:
* [(vehicle acre_player), acre_player, true] call acre_sys_intercom_fnc_handleBroadcasting
*
* Public: No
*/
params ["_vehicle", "_unit", "_intercomNetwork", "_isBroadcasting"];
private _broadcastConfig = _vehicle getVariable [QGVAR(broadcasting), []];
GVAR(broadcastKey) = _isBroadcasting;
private _changes = false;
{
if ((_intercomNetwork == _forEachIndex || {_intercomNetwork == ALL_INTERCOMS})) then {
if (_isBroadcasting) then {
_broadcastConfig set [_forEachIndex, [_isBroadcasting, _unit]];
} else {
_broadcastConfig set [_forEachIndex, [_isBroadcasting, objNull]];
};
_changes = true;
};
} forEach (_vehicle getVariable [QGVAR(intercomNames), []]);
// Only broadcast if changes have been made.
// TODO: Remove synchronisation once intercom system has been converted to components and unique IDs.
// It will help in reduce the bandwith, since information will be exchanged through the TS plugin.
if (_changes) then {
[_vehicle, _unit] call FUNC(updateVehicleInfoText);
_vehicle setVariable [QGVAR(broadcasting), _broadcastConfig, true];
if (_isBroadcasting) then {
["startIntercomSpeaking", ""] call EFUNC(sys_rpc,callRemoteProcedure);
} else {
["stopIntercomSpeaking", ""] call EFUNC(sys_rpc,callRemoteProcedure);
};
};