-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbroadcast.sqf
81 lines (68 loc) · 2.15 KB
/
broadcast.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
broadcast_make_key = {
private["_id"];
_id = _this select 0;
if (isNil "_id") exitWith {};
if (typeName _id != "SCALAR") exitWith{};
format["dnicepub_Pstr_%1",_id];
};
broadcast_receive = {
private["_value"];
_code = _this select 1;
if (isNil "_code") exitWith{};
if (typeName _code != "STRING") exitWith {};
/*if(isServer) then {
diag_log format ["RECEIVED BROADCASTED: %1", _code];
};*/
call compile _code;
};
broadcast = {
private["_code"];
_code = _this;
if (isNil "_code") exitWith {};
if (typeName _code != "STRING") exitWith {};
/*if(isServer) then {
diag_log format ["SENT BROADCASTED: %1", _code];
};*/
missionNamespace setVariable [player_broadcast_buffer, _code];
publicVariable player_broadcast_buffer;
call compile _code;
};
broadcast_server = {
private["_code"];
_code = _this;
if (isNil "_code") exitWith {};
if (typeName _code != "STRING") exitWith {};
missionNamespace setVariable [player_broadcast_buffer, _code];
publicVariableServer player_broadcast_buffer;
};
broadcast_client = {
private["_code", "_client"];
_code = _this select 0;
_client = _this select 1;
if (isNil "_code") exitWith {};
if (typeName _code != "STRING") exitWith {};
if ((typeName _client) == "OBJECT") then {_client = owner _client};
if ((typeName _client) != "SCALAR") exitwith {};
missionNamespace setVariable [player_broadcast_buffer, _code];
_client publicVariableClient player_broadcast_buffer;
};
broadcast_setup = {
private["_player_number", "_player_count"];
_player_number = _this select 0;
_player_count = _this select 1;
if (isNil "_player_number") exitWith {};
if (isNil "_player_count") exitWith {};
if (typeName _player_number != "SCALAR") exitWith {};
if (typeName _player_count != "SCALAR") exitWith {};
player_broadcast_buffer = [_player_number] call broadcast_make_key;
private["_i"];
_i = 0;
while { _i < _player_count } do {
private["_variable_name"];
_variable_name = [_i] call broadcast_make_key;
missionNamespace setVariable [_variable_name, ""];
_variable_name addPublicVariableEventHandler { _this call broadcast_receive;};
_i = _i + 1;
};
};
[rolenumber, (count PlayerStringArray)] call broadcast_setup;