forked from IDI-Systems/acre2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnc_handleLimitedConnection.sqf
48 lines (43 loc) · 1.48 KB
/
fnc_handleLimitedConnection.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
#include "script_component.hpp"
/*
* Author: ACRE2Team
* Sets the intercom connection status of a limited intercom station.
*
* Arguments:
* 0: Vehicle with intercom <OBJECT>
* 1: Intercom network <NUMBER>
* 2: Connection status <NUMBER>
* 3: Previous connection status <NUMBER>
*
* Return Value:
* Success <BOOL>
*
* Example:
* [vehicle acre_player, acre_player, 1, 0] call acre_sys_intercom_fnc_handleLimitedConnection
*
* Public: No
*/
params ["_vehicle", "_intercomNetwork", "_newConnectedStatus", "_oldConnectedStatus"];
private _numLimitedPositions = (_vehicle getVariable [QGVAR(numLimitedPositions), []]);
private _num = _numLimitedPositions select _intercomNetwork;
private _success = false;
if (_newConnectedStatus > INTERCOM_DISCONNECTED) then {
if (_oldConnectedStatus > INTERCOM_DISCONNECTED) then {
// Unit is already connected
_success = true;
} else {
// Unit is connecting. Check if there are still available connections
if (_num > 0) then {
_numLimitedPositions set [_intercomNetwork, _num - 1];
_vehicle setVariable [QGVAR(numLimitedPositions), _numLimitedPositions, true];
_success = true;
} else {
[[ICON_RADIO_CALL], [localize LSTRING(maxConnections)]] call CBA_fnc_notify;
};
};
} else {
_numLimitedPositions set [_intercomNetwork, _num + 1];
_vehicle setVariable [QGVAR(numLimitedPositions), _numLimitedPositions, true];
_success = true;
};
_success