forked from LexTheGreat/TLX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gangs.sqf
222 lines (171 loc) · 6.16 KB
/
gangs.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
liafu = true;
_this = _this select 3;
_art = _this select 0;
if(_art == "create") then {
_text = _this select 1;
_name = name player;
_moneh = [player, 'money'] call INV_GetItemAmount;
_exitvar = false;
if(_text == "cops") exitWith {
player groupchat "you cannot use that name"
};
if(gangmember) exitWith {
player groupchat "you are already in a gang!"
};
for "_c" from 0 to (count gangsarray - 1) do {
if (((gangsarray select _c) select 0) == _text) exitWith {_exitvar = true;};
};
if(_exitvar) exitWith {
player groupchat "a gang with the same name already exists!"
};
if ((_text call dnicestr_Length) > 30 or (_text call dnicestr_Length) < 3) exitWith {
player groupChat "the entered text is either too long or too short";
};
if(_moneh < gangcreatecost) exitWith {
player groupchat "not enough money"
};
[player, 'money', -gangcreatecost] call INV_AddInventoryItem;
format['gangsarray = gangsarray + [["%1", ["%2"], true]]', _text, _name] call broadcast;
player groupchat format["you have created a new gang called %1!", _text];
gangmember=true;
};
if(_art == "join") then {
_gang = _this select 1;
_name = name player;
_id = -1;
if(gangmember) exitWith {
player groupchat "you are already in a gang!"
};
for "_c" from 0 to (count gangsarray - 1) do {
if (((gangsarray select _c) select 0) == _gang) exitWith {
_id = _c;
};
};
if(_id == -1) exitWith {
player groupchat "this gang no longer exists!"
};
_gangarray = gangsarray select _id;
_members = _gangarray select 1;
_canjoin = _gangarray select 2;
if(!_canjoin) exitWith {
player groupchat "the leader of this gang is not currently not recruiting"
};
_members = _members + [_name];
_gangarray set[1, _members];
format['gangsarray set[%1, %2]', _id, _gangarray] call broadcast;
player groupchat format["you have joined %1!", _gang];
};
if(_art == "leave") then {
if(!gangmember)exitwith{player groupchat "you are not in a gang!"};
for "_c" from 0 to (count gangsarray - 1) do {
_gangarray = gangsarray select _c;
_gang = _gangarray select 0;
_members = _gangarray select 1;
_name = name player;
if(_name in _members)then {
_members = _members - [_name];
_gangarray set[1, _members];
format['gangsarray set[%1, %2]', _c, _gangarray] call broadcast;
player groupchat "you left your gang!";
gangmember=false;
};
};
};
if(_art == "kick") then {
if((_this select 1) == "notingame") exitWith {
player groupchat "you cannot kick members unless they are ingame! Offline members are removed every 2 minutes"
};
player groupchat format ["%1", _this];
_civ = call compile format["%1", _this select 1];
if(player == _civ) exitWith {
player groupchat "you cannot kick yourself!"
};
for "_c" from 0 to (count gangsarray - 1) do {
_gangarray = gangsarray select _c;
_gang = _gangarray select 0;
_members = _gangarray select 1;
_name = name player;
if(_name in _members)then {
_members = _members - [(name _civ)];
_gangarray set[1, _members];
format['if(player == %3)then{player groupchat "you have been kicked out of your gang!"; gangmember = false;}; gangsarray set[%1, %2]', _c, _gangarray, _civ] call broadcast;
};
player groupchat format["you kicked %1 from your gang!", name _civ];
};
};
if(_art == "allowjoin") then {
if(_this select 1 == "") exitWith {
player groupchat "you must select either yes or no!"
};
_bool = call compile format["%1", _this select 1];
for "_c" from 0 to (count gangsarray - 1) do {
_gangarray = gangsarray select _c;
_gang = _gangarray select 0;
_members = _gangarray select 1;
_name = name player;
if(_name in _members)then {
_gangarray set[2, _bool];
format['gangsarray set[%1, %2]', _c, _gangarray] call broadcast;
if(_bool)then{player groupchat "civilians can now join your gang"}else{player groupchat "civilians can no longer join your gang"};
};
};
};
if(_art == "clientloop") then {
sleep 10;
private ["_mygang", "_mymembers", "_enmembers"];
startgroup = group player;
for "_c" from 0 to (count gangsarray - 1) do {
_gangarray = gangsarray select _c;
_gang = _gangarray select 0;
_members = _gangarray select 1;
_name = name player;
if(_name in _members and not([player] call player_civilian))then {
_members = _members - [_name];
_gangarray set[1, _members];
format['gangsarray set[%1, %2]', _c, _gangarray] call broadcast;
};
};
while {isCiv} do {
for "_c" from 0 to (count gangsarray - 1) do {
_gangarray = gangsarray select _c;
_gang = _gangarray select 0;
_members = _gangarray select 1;
if(count _members > 0) then {
_leader = _members select 0;
_lunit = [_leader] call player_lookup_name;
private["_leader_active"];
_leader_active = ([_lunit] call player_civilian);
if (not(_leader_active) && not(player in (units startgroup))) then {
[player] joinsilent startgroup;
};
if (not(_leader_active)) exitWith {};
_group = group _lunit;
_name = name player;
if(leader _group != _lunit)then{_group selectleader _lunit};
if(player == _lunit and !gangleader)then{gangleader = true; [player] joinsilent startgroup;};
if(gangleader and player != _lunit and _name in _members)then{gangleader = false};
if(_name in _members and !gangmember)then{gangmember = true};
if(_name in _members and gangmember)then{_mygang = _gang; _mymembers = _members};
if(_name in _members and player != _lunit and !(player in (units _group))) then {[player] joinsilent _group;};
};
};
if(!gangmember and !(player in (units startgroup)))then{[player] joinsilent startgroup};
for "_c" from 0 to (count gangareas - 1) do {
private ["_pos"];
_gangarea = gangareas select _c;
_control = _gangarea getVariable "control";
_offset = [_gangarea] call flag_gang_get_offset;
if ((!isNil "_offset")) then
{
if(!isNil "_control") then {
if(player distance _gangarea < 10 and (_offset select 2) < 0 and _control == call INV_MyGang)then {
_new_offset = [_gangarea, [0,0,0.1]] call flag_gang_set_offset;
if ((_new_offset select 2) > 0) then {
[_gangarea, [0,0,0]] call flag_gang_reset_offset;
};
};};
};
};
sleep 1;
};
};