forked from IDI-Systems/acre2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnc_server.sqf
83 lines (79 loc) · 2.92 KB
/
fnc_server.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "script_component.hpp"
/*
* Author: ACRE2Team
* Creates a PFH to monitor the ACRE2Arma extension's connection to the TeamSpeak plugin.
*
* Arguments:
* None
*
* Return Value:
* Successful <BOOL>
*
* Example:
* [] call acre_sys_io_fnc_server
*
* Public: No
*/
GVAR(pipeCode) = "0";
DFUNC(connectionFnc) = {
LOG("~~~~~~~~~~~~~CONNNNNECTION FUNNNNNNCTION CALLED!!!!!!!!!!!!!!!!!");
if (GVAR(runServer)) then {
if (GVAR(pipeCode) != "1") then {
LOG("ATEEEMPTING TO OPEN PIPE!");
// acre_player sideChat "OPEN PIPE";
GVAR(pongTime) = diag_tickTime;
GVAR(pipeCode) = "ACRE2Arma" callExtension "0ts"; // Connect String
// acre_player sideChat format["RESULT: %1", GVAR(pipeCode)];
if (GVAR(pipeCode) != "1") then {
if (time > 15) then {
#ifndef DEBUG_MODE_FULL
if (!is3DENPreview) then {
#endif
if ((missionNamespace getVariable [QGVAR(notConnectedTime), -15]) + 30 < time ) then {
GVAR(notConnectedTime) = time;
private _warning = format ["<t color='#FF8021'>WARNING!</t><br/> %1", localize LSTRING(acreNotConnected)];
[[_warning, 1.5]] call CBA_fnc_notify;
};
GVAR(connectCount) = GVAR(connectCount) + 1;
if (GVAR(connectCount) > 15) then {
INFO_1("Pipe error: %1",GVAR(pipeCode));
GVAR(connectCount) = 0;
#ifndef DEBUG_MODE_FULL
};
#endif
};
LOG("Client not responding, trying again.");
};
GVAR(serverStarted) = false;
//diag_log text format["%1 ACRE: Pipe failed opening: %2", diag_tickTime, GVAR(pipeCode)];
} else {
LOG("PIPE OPENED!");
if (GVAR(hasErrored)) then {
[[format ["<t color='#2B7319'>%1</t>", localize LSTRING(recoveredClosedPipe)], 1.5]] call CBA_fnc_notify;
} else {
[format ["<t color='#2B7319'>%1</t>", localize LSTRING(acreConnected)]] call CBA_fnc_notify;
};
GVAR(hasErrored) = false;
INFO("Pipe opened.");
GVAR(serverStarted) = true;
// Move TeamSpeak 3 channel if already in-game (otherwise display XEH will take care of it)
if (!isNull (findDisplay 46)) then {
call FUNC(ts3ChannelMove);
};
};
};
} else {
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
true
};
#ifndef DEBUG_MODE_FULL
if (isMultiplayer) then {
#endif
[] call FUNC(connectionFnc);
[DFUNC(connectionFnc), 1, []] call CBA_fnc_addPerFrameHandler;
GVAR(serverStarted) = true;
#ifndef DEBUG_MODE_FULL
};
#endif
true