Parent Directory | Revision Log
Revision 44 - (view) (download)
1 : | ian | 1 | /* AMX Mod X |
2 : | * Players Menu Plugin | ||
3 : | * | ||
4 : | * by the AMX Mod X Development Team | ||
5 : | * originally developed by OLO | ||
6 : | * | ||
7 : | * This file is part of AMX Mod X. | ||
8 : | * | ||
9 : | * | ||
10 : | * This program is free software; you can redistribute it and/or modify it | ||
11 : | * under the terms of the GNU General Public License as published by the | ||
12 : | * Free Software Foundation; either version 2 of the License, or (at | ||
13 : | * your option) any later version. | ||
14 : | * | ||
15 : | * This program is distributed in the hope that it will be useful, but | ||
16 : | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18 : | * General Public License for more details. | ||
19 : | * | ||
20 : | * You should have received a copy of the GNU General Public License | ||
21 : | * along with this program; if not, write to the Free Software Foundation, | ||
22 : | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 : | * | ||
24 : | * In addition, as a special exception, the author gives permission to | ||
25 : | * link the code of this program with the Half-Life Game Engine ("HL | ||
26 : | * Engine") and Modified Game Libraries ("MODs") developed by Valve, | ||
27 : | * L.L.C ("Valve"). You must obey the GNU General Public License in all | ||
28 : | * respects for all of the code used other than the HL Engine and MODs | ||
29 : | * from Valve. If you modify this file, you may extend this exception | ||
30 : | * to your version of the file, but you are not obligated to do so. If | ||
31 : | * you do not wish to do so, delete this exception statement from your | ||
32 : | * version. | ||
33 : | */ | ||
34 : | |||
35 : | #include <amxmodx> | ||
36 : | #include <amxmisc> | ||
37 : | |||
38 : | /** skip autoloading since it's optional */ | ||
39 : | #define AMXMODX_NOAUTOLOAD | ||
40 : | #include <cstrike> | ||
41 : | |||
42 : | new g_menuPosition[33] | ||
43 : | new g_menuPlayers[33][32] | ||
44 : | new g_menuPlayersNum[33] | ||
45 : | new g_menuOption[33] | ||
46 : | new g_menuSettings[33] | ||
47 : | |||
48 : | new g_menuSelect[33][64] | ||
49 : | new g_menuSelectNum[33] | ||
50 : | |||
51 : | #define MAX_CLCMDS 24 | ||
52 : | |||
53 : | new g_clcmdName[MAX_CLCMDS][32] | ||
54 : | new g_clcmdCmd[MAX_CLCMDS][64] | ||
55 : | new g_clcmdMisc[MAX_CLCMDS][2] | ||
56 : | new g_clcmdNum | ||
57 : | |||
58 : | new g_coloredMenus | ||
59 : | new g_cstrike = 0 | ||
60 : | |||
61 : | ian | 17 | new Array:g_bantimes; |
62 : | new Array:g_slapsettings; | ||
63 : | |||
64 : | new g_CSTeamNames[3][] = { | ||
65 : | "TERRORIST", | ||
66 : | "CT", | ||
67 : | "SPECTATOR" | ||
68 : | } | ||
69 : | new g_CSTeamNumbers[3][] = { | ||
70 : | "1", | ||
71 : | "2", | ||
72 : | "6" | ||
73 : | } | ||
74 : | new g_CSTeamiNumbers[3] = { | ||
75 : | 1, | ||
76 : | 2, | ||
77 : | 6 | ||
78 : | } | ||
79 : | |||
80 : | |||
81 : | ian | 1 | public plugin_natives() |
82 : | { | ||
83 : | set_module_filter("module_filter") | ||
84 : | set_native_filter("native_filter") | ||
85 : | } | ||
86 : | |||
87 : | public plugin_init() | ||
88 : | { | ||
89 : | register_plugin("Players Menu", AMXX_VERSION_STR, "AMXX Dev Team") | ||
90 : | register_dictionary("common.txt") | ||
91 : | register_dictionary("admincmd.txt") | ||
92 : | register_dictionary("plmenu.txt") | ||
93 : | |||
94 : | register_clcmd("amx_kickmenu", "cmdKickMenu", ADMIN_KICK, "- displays kick menu") | ||
95 : | register_clcmd("amx_banmenu", "cmdBanMenu", ADMIN_BAN, "- displays ban menu") | ||
96 : | register_clcmd("amx_slapmenu", "cmdSlapMenu", ADMIN_SLAY, "- displays slap/slay menu") | ||
97 : | register_clcmd("amx_teammenu", "cmdTeamMenu", ADMIN_LEVEL_A, "- displays team menu") | ||
98 : | register_clcmd("amx_clcmdmenu", "cmdClcmdMenu", ADMIN_LEVEL_A, "- displays client cmds menu") | ||
99 : | |||
100 : | register_menucmd(register_menuid("Ban Menu"), 1023, "actionBanMenu") | ||
101 : | register_menucmd(register_menuid("Kick Menu"), 1023, "actionKickMenu") | ||
102 : | register_menucmd(register_menuid("Slap/Slay Menu"), 1023, "actionSlapMenu") | ||
103 : | register_menucmd(register_menuid("Team Menu"), 1023, "actionTeamMenu") | ||
104 : | register_menucmd(register_menuid("Client Cmds Menu"), 1023, "actionClcmdMenu") | ||
105 : | ian | 17 | |
106 : | |||
107 : | g_bantimes = ArrayCreate(); | ||
108 : | // Load up the old default values | ||
109 : | ArrayPushCell(g_bantimes, 0); | ||
110 : | ArrayPushCell(g_bantimes, 5); | ||
111 : | ArrayPushCell(g_bantimes, 10); | ||
112 : | ArrayPushCell(g_bantimes, 15); | ||
113 : | ArrayPushCell(g_bantimes, 30); | ||
114 : | ArrayPushCell(g_bantimes, 45); | ||
115 : | ArrayPushCell(g_bantimes, 60); | ||
116 : | |||
117 : | |||
118 : | g_slapsettings = ArrayCreate(); | ||
119 : | // Old default values | ||
120 : | ArrayPushCell(g_slapsettings, 0); // First option is ignored - it is slay | ||
121 : | ian | 44 | ArrayPushCell(g_slapsettings, 0); // slap 0 damage |
122 : | ian | 17 | ArrayPushCell(g_slapsettings, 1); |
123 : | ArrayPushCell(g_slapsettings, 5); | ||
124 : | |||
125 : | |||
126 : | register_srvcmd("amx_plmenu_bantimes", "plmenu_setbantimes"); | ||
127 : | register_srvcmd("amx_plmenu_slapdmg", "plmenu_setslapdmg"); | ||
128 : | ian | 1 | |
129 : | g_coloredMenus = colored_menus() | ||
130 : | |||
131 : | new clcmds_ini_file[64] | ||
132 : | get_configsdir(clcmds_ini_file, 63) | ||
133 : | format(clcmds_ini_file, 63, "%s/clcmds.ini", clcmds_ini_file) | ||
134 : | load_settings(clcmds_ini_file) | ||
135 : | |||
136 : | if (module_exists("cstrike")) | ||
137 : | g_cstrike = 1 | ||
138 : | } | ||
139 : | ian | 17 | public plmenu_setbantimes() |
140 : | { | ||
141 : | new buff[32]; | ||
142 : | new args = read_argc(); | ||
143 : | |||
144 : | if (args <= 1) | ||
145 : | { | ||
146 : | server_print("usage: amx_plmenu_bantimes <time1> [time2] [time3] ..."); | ||
147 : | server_print(" use time of 0 for permanent."); | ||
148 : | |||
149 : | return; | ||
150 : | } | ||
151 : | |||
152 : | ArrayClear(g_bantimes); | ||
153 : | |||
154 : | for (new i = 1; i < args; i++) | ||
155 : | { | ||
156 : | read_argv(i, buff, charsmax(buff)); | ||
157 : | |||
158 : | ArrayPushCell(g_bantimes, str_to_num(buff)); | ||
159 : | |||
160 : | } | ||
161 : | |||
162 : | } | ||
163 : | public plmenu_setslapdmg() | ||
164 : | { | ||
165 : | new buff[32]; | ||
166 : | new args = read_argc(); | ||
167 : | |||
168 : | if (args <= 1) | ||
169 : | { | ||
170 : | server_print("usage: amx_plmenu_slapdmg <dmg1> [dmg2] [dmg3] ..."); | ||
171 : | server_print(" slay is automatically set for the first value."); | ||
172 : | |||
173 : | return; | ||
174 : | } | ||
175 : | |||
176 : | ArrayClear(g_slapsettings); | ||
177 : | |||
178 : | ArrayPushCell(g_slapsettings, 0); // compensate for slay | ||
179 : | |||
180 : | for (new i = 1; i < args; i++) | ||
181 : | { | ||
182 : | read_argv(i, buff, charsmax(buff)); | ||
183 : | |||
184 : | ArrayPushCell(g_slapsettings, str_to_num(buff)); | ||
185 : | |||
186 : | } | ||
187 : | |||
188 : | } | ||
189 : | ian | 1 | public module_filter(const module[]) |
190 : | { | ||
191 : | if (equali(module, "cstrike")) | ||
192 : | return PLUGIN_HANDLED | ||
193 : | |||
194 : | return PLUGIN_CONTINUE | ||
195 : | } | ||
196 : | |||
197 : | public native_filter(const name[], index, trap) | ||
198 : | { | ||
199 : | if (!trap) | ||
200 : | return PLUGIN_HANDLED | ||
201 : | |||
202 : | return PLUGIN_CONTINUE | ||
203 : | } | ||
204 : | |||
205 : | /* Ban menu */ | ||
206 : | |||
207 : | public actionBanMenu(id, key) | ||
208 : | { | ||
209 : | switch (key) | ||
210 : | { | ||
211 : | case 7: | ||
212 : | { | ||
213 : | /* BEGIN OF CHANGES BY MISTAGEE ADDED A FEW MORE OPTIONS */ | ||
214 : | |||
215 : | ++g_menuOption[id] | ||
216 : | ian | 17 | g_menuOption[id] %= ArraySize(g_bantimes); |
217 : | ian | 1 | |
218 : | ian | 17 | g_menuSettings[id] = ArrayGetCell(g_bantimes, g_menuOption[id]); |
219 : | ian | 1 | |
220 : | displayBanMenu(id, g_menuPosition[id]) | ||
221 : | } | ||
222 : | case 8: displayBanMenu(id, ++g_menuPosition[id]) | ||
223 : | case 9: displayBanMenu(id, --g_menuPosition[id]) | ||
224 : | default: | ||
225 : | { | ||
226 : | new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] | ||
227 : | new name[32], name2[32], authid[32], authid2[32] | ||
228 : | |||
229 : | get_user_name(player, name2, 31) | ||
230 : | get_user_authid(id, authid, 31) | ||
231 : | get_user_authid(player, authid2, 31) | ||
232 : | get_user_name(id, name, 31) | ||
233 : | |||
234 : | new userid2 = get_user_userid(player) | ||
235 : | |||
236 : | log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")", name, get_user_userid(id), authid, name2, userid2, authid2, g_menuSettings[id]) | ||
237 : | |||
238 : | ian | 17 | if (g_menuSettings[id]==0) // permanent |
239 : | ian | 1 | { |
240 : | ian | 17 | new maxpl = get_maxplayers(); |
241 : | for (new i = 1; i <= maxpl; i++) | ||
242 : | { | ||
243 : | show_activity_id(i, id, name, "%L %s %L", i, "BAN", name2, i, "PERM"); | ||
244 : | } | ||
245 : | ian | 1 | } |
246 : | ian | 17 | else |
247 : | { | ||
248 : | new tempTime[32]; | ||
249 : | formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]); | ||
250 : | new maxpl = get_maxplayers(); | ||
251 : | for (new i = 1; i <= maxpl; i++) | ||
252 : | { | ||
253 : | show_activity_id(i, id, name, "%L %s %L", i, "BAN", name2, i, "FOR_MIN", tempTime); | ||
254 : | } | ||
255 : | } | ||
256 : | ian | 1 | /* ---------- check for Steam ID added by MistaGee -------------------- |
257 : | IF AUTHID == 4294967295 OR VALVE_ID_LAN OR HLTV, BAN PER IP TO NOT BAN EVERYONE */ | ||
258 : | |||
259 : | if (equal("4294967295", authid2) | ||
260 : | || equal("HLTV", authid2) | ||
261 : | || equal("STEAM_ID_LAN", authid2) | ||
262 : | || equali("VALVE_ID_LAN", authid2)) | ||
263 : | { | ||
264 : | /* END OF MODIFICATIONS BY MISTAGEE */ | ||
265 : | new ipa[32] | ||
266 : | get_user_ip(player, ipa, 31, 1) | ||
267 : | |||
268 : | server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa) | ||
269 : | } | ||
270 : | else | ||
271 : | ian | 17 | { |
272 : | ian | 1 | server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2) |
273 : | ian | 17 | } |
274 : | ian | 1 | |
275 : | server_exec() | ||
276 : | |||
277 : | displayBanMenu(id, g_menuPosition[id]) | ||
278 : | } | ||
279 : | } | ||
280 : | |||
281 : | return PLUGIN_HANDLED | ||
282 : | } | ||
283 : | |||
284 : | displayBanMenu(id, pos) | ||
285 : | { | ||
286 : | if (pos < 0) | ||
287 : | return | ||
288 : | |||
289 : | get_players(g_menuPlayers[id], g_menuPlayersNum[id]) | ||
290 : | |||
291 : | new menuBody[512] | ||
292 : | new b = 0 | ||
293 : | new i | ||
294 : | new name[32] | ||
295 : | new start = pos * 7 | ||
296 : | |||
297 : | if (start >= g_menuPlayersNum[id]) | ||
298 : | start = pos = g_menuPosition[id] = 0 | ||
299 : | |||
300 : | new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "BAN_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) | ||
301 : | new end = start + 7 | ||
302 : | new keys = MENU_KEY_0|MENU_KEY_8 | ||
303 : | |||
304 : | if (end > g_menuPlayersNum[id]) | ||
305 : | end = g_menuPlayersNum[id] | ||
306 : | |||
307 : | for (new a = start; a < end; ++a) | ||
308 : | { | ||
309 : | i = g_menuPlayers[id][a] | ||
310 : | get_user_name(i, name, 31) | ||
311 : | |||
312 : | ian | 44 | if (is_user_bot(i) || (access(i, ADMIN_IMMUNITY) && i != id)) |
313 : | ian | 1 | { |
314 : | ++b | ||
315 : | |||
316 : | if (g_coloredMenus) | ||
317 : | len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) | ||
318 : | else | ||
319 : | len += format(menuBody[len], 511-len, "#. %s^n", name) | ||
320 : | } else { | ||
321 : | keys |= (1<<b) | ||
322 : | |||
323 : | if (is_user_admin(i)) | ||
324 : | len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name) | ||
325 : | else | ||
326 : | len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name) | ||
327 : | } | ||
328 : | } | ||
329 : | |||
330 : | if (g_menuSettings[id]) | ||
331 : | len += format(menuBody[len], 511-len, "^n8. %L^n", id, "BAN_FOR_MIN", g_menuSettings[id]) | ||
332 : | else | ||
333 : | len += format(menuBody[len], 511-len, "^n8. %L^n", id, "BAN_PERM") | ||
334 : | |||
335 : | if (end != g_menuPlayersNum[id]) | ||
336 : | { | ||
337 : | format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") | ||
338 : | keys |= MENU_KEY_9 | ||
339 : | } | ||
340 : | else | ||
341 : | format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT") | ||
342 : | |||
343 : | show_menu(id, keys, menuBody, -1, "Ban Menu") | ||
344 : | } | ||
345 : | |||
346 : | public cmdBanMenu(id, level, cid) | ||
347 : | { | ||
348 : | if (!cmd_access(id, level, cid, 1)) | ||
349 : | return PLUGIN_HANDLED | ||
350 : | |||
351 : | ian | 17 | g_menuOption[id] = 0 |
352 : | |||
353 : | if (ArraySize(g_bantimes) > 0) | ||
354 : | { | ||
355 : | g_menuSettings[id] = ArrayGetCell(g_bantimes, g_menuOption[id]); | ||
356 : | } | ||
357 : | else | ||
358 : | { | ||
359 : | // should never happen, but failsafe | ||
360 : | g_menuSettings[id] = 0 | ||
361 : | } | ||
362 : | ian | 1 | displayBanMenu(id, g_menuPosition[id] = 0) |
363 : | |||
364 : | return PLUGIN_HANDLED | ||
365 : | } | ||
366 : | |||
367 : | /* Slap/Slay */ | ||
368 : | |||
369 : | public actionSlapMenu(id, key) | ||
370 : | { | ||
371 : | switch (key) | ||
372 : | { | ||
373 : | case 7: | ||
374 : | { | ||
375 : | ++g_menuOption[id] | ||
376 : | |||
377 : | ian | 17 | g_menuOption[id] %= ArraySize(g_slapsettings); |
378 : | ian | 1 | |
379 : | ian | 17 | g_menuSettings[id] = ArrayGetCell(g_slapsettings, g_menuOption[id]); |
380 : | |||
381 : | displaySlapMenu(id, g_menuPosition[id]); | ||
382 : | ian | 1 | } |
383 : | case 8: displaySlapMenu(id, ++g_menuPosition[id]) | ||
384 : | case 9: displaySlapMenu(id, --g_menuPosition[id]) | ||
385 : | default: | ||
386 : | { | ||
387 : | new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] | ||
388 : | new name2[32] | ||
389 : | |||
390 : | get_user_name(player, name2, 31) | ||
391 : | |||
392 : | if (!is_user_alive(player)) | ||
393 : | { | ||
394 : | client_print(id, print_chat, "%L", id, "CANT_PERF_DEAD", name2) | ||
395 : | displaySlapMenu(id, g_menuPosition[id]) | ||
396 : | return PLUGIN_HANDLED | ||
397 : | } | ||
398 : | |||
399 : | new authid[32], authid2[32], name[32] | ||
400 : | |||
401 : | get_user_authid(id, authid, 31) | ||
402 : | get_user_authid(player, authid2, 31) | ||
403 : | get_user_name(id, name, 31) | ||
404 : | |||
405 : | if (g_menuOption[id]) | ||
406 : | { | ||
407 : | log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, g_menuSettings[id], name2, get_user_userid(player), authid2) | ||
408 : | ian | 17 | |
409 : | show_activity_key("ADMIN_SLAP_1", "ADMIN_SLAP_2", name, name2, g_menuSettings[id]); | ||
410 : | ian | 1 | } else { |
411 : | log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2) | ||
412 : | |||
413 : | ian | 17 | show_activity_key("ADMIN_SLAY_1", "ADMIN_SLAY_2", name, name2); |
414 : | ian | 1 | } |
415 : | |||
416 : | if (g_menuOption[id]) | ||
417 : | user_slap(player, (get_user_health(player) > g_menuSettings[id]) ? g_menuSettings[id] : 0) | ||
418 : | else | ||
419 : | user_kill(player) | ||
420 : | |||
421 : | displaySlapMenu(id, g_menuPosition[id]) | ||
422 : | } | ||
423 : | } | ||
424 : | |||
425 : | return PLUGIN_HANDLED | ||
426 : | } | ||
427 : | |||
428 : | displaySlapMenu(id, pos) | ||
429 : | { | ||
430 : | if (pos < 0) | ||
431 : | return | ||
432 : | |||
433 : | get_players(g_menuPlayers[id], g_menuPlayersNum[id]) | ||
434 : | |||
435 : | new menuBody[512] | ||
436 : | new b = 0 | ||
437 : | new i | ||
438 : | new name[32], team[4] | ||
439 : | new start = pos * 7 | ||
440 : | |||
441 : | if (start >= g_menuPlayersNum[id]) | ||
442 : | start = pos = g_menuPosition[id] = 0 | ||
443 : | |||
444 : | new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "SLAP_SLAY_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) | ||
445 : | new end = start + 7 | ||
446 : | new keys = MENU_KEY_0|MENU_KEY_8 | ||
447 : | |||
448 : | if (end > g_menuPlayersNum[id]) | ||
449 : | end = g_menuPlayersNum[id] | ||
450 : | |||
451 : | for (new a = start; a < end; ++a) | ||
452 : | { | ||
453 : | i = g_menuPlayers[id][a] | ||
454 : | get_user_name(i, name, 31) | ||
455 : | |||
456 : | if (g_cstrike) | ||
457 : | { | ||
458 : | if (cs_get_user_team(i) == CS_TEAM_T) | ||
459 : | { | ||
460 : | copy(team, 3, "TE") | ||
461 : | } | ||
462 : | else if (cs_get_user_team(i) == CS_TEAM_CT) | ||
463 : | { | ||
464 : | copy(team, 3, "CT") | ||
465 : | } else { | ||
466 : | get_user_team(i, team, 3) | ||
467 : | } | ||
468 : | } else { | ||
469 : | get_user_team(i, team, 3) | ||
470 : | } | ||
471 : | |||
472 : | ian | 44 | if (!is_user_alive(i) || (access(i, ADMIN_IMMUNITY) && i != id)) |
473 : | ian | 1 | { |
474 : | ++b | ||
475 : | |||
476 : | if (g_coloredMenus) | ||
477 : | len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team) | ||
478 : | else | ||
479 : | len += format(menuBody[len], 511-len, "#. %s %s^n", name, team) | ||
480 : | } else { | ||
481 : | keys |= (1<<b) | ||
482 : | |||
483 : | if (is_user_admin(i)) | ||
484 : | len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*\y\R%s^n\w" : "%d. %s * %s^n", ++b, name, team) | ||
485 : | else | ||
486 : | len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++b, name, team) | ||
487 : | } | ||
488 : | } | ||
489 : | |||
490 : | if (g_menuOption[id]) | ||
491 : | len += format(menuBody[len], 511-len, "^n8. %L^n", id, "SLAP_WITH_DMG", g_menuSettings[id]) | ||
492 : | else | ||
493 : | len += format(menuBody[len], 511-len, "^n8. %L^n", id, "SLAY") | ||
494 : | |||
495 : | if (end != g_menuPlayersNum[id]) | ||
496 : | { | ||
497 : | format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") | ||
498 : | keys |= MENU_KEY_9 | ||
499 : | } | ||
500 : | else | ||
501 : | format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT") | ||
502 : | |||
503 : | show_menu(id, keys, menuBody, -1, "Slap/Slay Menu") | ||
504 : | } | ||
505 : | |||
506 : | public cmdSlapMenu(id, level, cid) | ||
507 : | { | ||
508 : | if (!cmd_access(id, level, cid, 1)) | ||
509 : | return PLUGIN_HANDLED | ||
510 : | |||
511 : | g_menuOption[id] = 0 | ||
512 : | ian | 17 | if (ArraySize(g_slapsettings) > 0) |
513 : | { | ||
514 : | g_menuSettings[id] = ArrayGetCell(g_slapsettings, g_menuOption[id]); | ||
515 : | } | ||
516 : | else | ||
517 : | { | ||
518 : | // should never happen, but failsafe | ||
519 : | g_menuSettings[id] = 0 | ||
520 : | } | ||
521 : | ian | 1 | |
522 : | displaySlapMenu(id, g_menuPosition[id] = 0) | ||
523 : | |||
524 : | return PLUGIN_HANDLED | ||
525 : | } | ||
526 : | |||
527 : | /* Kick */ | ||
528 : | |||
529 : | public actionKickMenu(id, key) | ||
530 : | { | ||
531 : | switch (key) | ||
532 : | { | ||
533 : | case 8: displayKickMenu(id, ++g_menuPosition[id]) | ||
534 : | case 9: displayKickMenu(id, --g_menuPosition[id]) | ||
535 : | default: | ||
536 : | { | ||
537 : | new player = g_menuPlayers[id][g_menuPosition[id] * 8 + key] | ||
538 : | new authid[32], authid2[32], name[32], name2[32] | ||
539 : | |||
540 : | get_user_authid(id, authid, 31) | ||
541 : | get_user_authid(player, authid2, 31) | ||
542 : | get_user_name(id, name, 31) | ||
543 : | get_user_name(player, name2, 31) | ||
544 : | |||
545 : | new userid2 = get_user_userid(player) | ||
546 : | |||
547 : | log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, userid2, authid2) | ||
548 : | |||
549 : | ian | 17 | show_activity_key("ADMIN_KICK_1", "ADMIN_KICK_2", name, name2); |
550 : | ian | 1 | |
551 : | ian | 17 | |
552 : | ian | 1 | server_cmd("kick #%d", userid2) |
553 : | server_exec() | ||
554 : | |||
555 : | displayKickMenu(id, g_menuPosition[id]) | ||
556 : | } | ||
557 : | } | ||
558 : | |||
559 : | return PLUGIN_HANDLED | ||
560 : | } | ||
561 : | |||
562 : | displayKickMenu(id, pos) | ||
563 : | { | ||
564 : | if (pos < 0) | ||
565 : | return | ||
566 : | |||
567 : | get_players(g_menuPlayers[id], g_menuPlayersNum[id]) | ||
568 : | |||
569 : | new menuBody[512] | ||
570 : | new b = 0 | ||
571 : | new i | ||
572 : | new name[32] | ||
573 : | new start = pos * 8 | ||
574 : | |||
575 : | if (start >= g_menuPlayersNum[id]) | ||
576 : | start = pos = g_menuPosition[id] = 0 | ||
577 : | |||
578 : | new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "KICK_MENU", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0))) | ||
579 : | new end = start + 8 | ||
580 : | new keys = MENU_KEY_0 | ||
581 : | |||
582 : | if (end > g_menuPlayersNum[id]) | ||
583 : | end = g_menuPlayersNum[id] | ||
584 : | |||
585 : | for (new a = start; a < end; ++a) | ||
586 : | { | ||
587 : | i = g_menuPlayers[id][a] | ||
588 : | get_user_name(i, name, 31) | ||
589 : | |||
590 : | ian | 44 | if (access(i, ADMIN_IMMUNITY) && i != id) |
591 : | ian | 1 | { |
592 : | ++b | ||
593 : | |||
594 : | if (g_coloredMenus) | ||
595 : | len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) | ||
596 : | else | ||
597 : | len += format(menuBody[len], 511-len, "#. %s^n", name) | ||
598 : | } else { | ||
599 : | keys |= (1<<b) | ||
600 : | |||
601 : | if (is_user_admin(i)) | ||
602 : | len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name) | ||
603 : | else | ||
604 : | len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name) | ||
605 : | } | ||
606 : | } | ||
607 : | |||
608 : | if (end != g_menuPlayersNum[id]) | ||
609 : | { | ||
610 : | format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") | ||
611 : | keys |= MENU_KEY_9 | ||
612 : | } | ||
613 : | else | ||
614 : | format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT") | ||
615 : | |||
616 : | show_menu(id, keys, menuBody, -1, "Kick Menu") | ||
617 : | } | ||
618 : | |||
619 : | public cmdKickMenu(id, level, cid) | ||
620 : | { | ||
621 : | if (cmd_access(id, level, cid, 1)) | ||
622 : | displayKickMenu(id, g_menuPosition[id] = 0) | ||
623 : | |||
624 : | return PLUGIN_HANDLED | ||
625 : | } | ||
626 : | |||
627 : | /* Team menu */ | ||
628 : | |||
629 : | public actionTeamMenu(id, key) | ||
630 : | { | ||
631 : | switch (key) | ||
632 : | { | ||
633 : | case 7: | ||
634 : | { | ||
635 : | ian | 17 | g_menuOption[id] = (g_menuOption[id] + 1) % (g_cstrike ? 3 : 2); |
636 : | ian | 1 | displayTeamMenu(id, g_menuPosition[id]) |
637 : | } | ||
638 : | case 8: displayTeamMenu(id, ++g_menuPosition[id]) | ||
639 : | case 9: displayTeamMenu(id, --g_menuPosition[id]) | ||
640 : | default: | ||
641 : | { | ||
642 : | new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] | ||
643 : | new authid[32], authid2[32], name[32], name2[32] | ||
644 : | |||
645 : | get_user_name(player, name2, 31) | ||
646 : | get_user_authid(id, authid, 31) | ||
647 : | get_user_authid(player, authid2, 31) | ||
648 : | get_user_name(id, name, 31) | ||
649 : | |||
650 : | log_amx("Cmd: ^"%s<%d><%s><>^" transfer ^"%s<%d><%s><>^" (team ^"%s^")", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2, g_menuOption[id] ? "TERRORIST" : "CT") | ||
651 : | |||
652 : | ian | 17 | show_activity_key("ADMIN_TRANSF_1", "ADMIN_TRANSF_2", name, name2, g_CSTeamNames[g_menuOption[id] % 3]); |
653 : | ian | 1 | |
654 : | if (g_cstrike) | ||
655 : | { | ||
656 : | if (is_user_alive(player)) | ||
657 : | { | ||
658 : | new deaths = cs_get_user_deaths(player) | ||
659 : | user_kill(player, 1) | ||
660 : | cs_set_user_deaths(player, deaths) | ||
661 : | } | ||
662 : | ian | 17 | // This modulo math just aligns the option to the CsTeams-corresponding number |
663 : | cs_set_user_team(player, (g_menuOption[id] % 3) + 1) | ||
664 : | ian | 1 | cs_reset_user_model(player) |
665 : | } else { | ||
666 : | new limit_setting = get_cvar_num("mp_limitteams") | ||
667 : | |||
668 : | set_cvar_num("mp_limitteams", 0) | ||
669 : | ian | 17 | engclient_cmd(player, "jointeam", g_CSTeamNumbers[g_menuOption[id] % 2]) |
670 : | ian | 1 | engclient_cmd(player, "joinclass", "1") |
671 : | set_cvar_num("mp_limitteams", limit_setting) | ||
672 : | } | ||
673 : | |||
674 : | displayTeamMenu(id, g_menuPosition[id]) | ||
675 : | } | ||
676 : | } | ||
677 : | |||
678 : | return PLUGIN_HANDLED | ||
679 : | } | ||
680 : | |||
681 : | displayTeamMenu(id, pos) | ||
682 : | { | ||
683 : | if (pos < 0) | ||
684 : | return | ||
685 : | |||
686 : | get_players(g_menuPlayers[id], g_menuPlayersNum[id]) | ||
687 : | |||
688 : | new menuBody[512] | ||
689 : | new b = 0 | ||
690 : | new i, iteam | ||
691 : | new name[32], team[4] | ||
692 : | new start = pos * 7 | ||
693 : | |||
694 : | if (start >= g_menuPlayersNum[id]) | ||
695 : | start = pos = g_menuPosition[id] = 0 | ||
696 : | |||
697 : | new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "TEAM_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) | ||
698 : | new end = start + 7 | ||
699 : | new keys = MENU_KEY_0|MENU_KEY_8 | ||
700 : | |||
701 : | if (end > g_menuPlayersNum[id]) | ||
702 : | end = g_menuPlayersNum[id] | ||
703 : | |||
704 : | for (new a = start; a < end; ++a) | ||
705 : | { | ||
706 : | i = g_menuPlayers[id][a] | ||
707 : | get_user_name(i, name, 31) | ||
708 : | |||
709 : | if (g_cstrike) | ||
710 : | { | ||
711 : | iteam = _:cs_get_user_team(i) | ||
712 : | |||
713 : | if (iteam == 1) | ||
714 : | { | ||
715 : | copy(team, 3, "TE") | ||
716 : | } | ||
717 : | else if (iteam == 2) | ||
718 : | { | ||
719 : | copy(team, 3, "CT") | ||
720 : | ian | 17 | } |
721 : | else if (iteam == 3) | ||
722 : | { | ||
723 : | copy(team, 3, "SPE"); | ||
724 : | iteam = 6; | ||
725 : | ian | 1 | } else { |
726 : | ian | 17 | iteam = get_user_team(i, team, 3) |
727 : | ian | 1 | } |
728 : | } else { | ||
729 : | iteam = get_user_team(i, team, 3) | ||
730 : | } | ||
731 : | |||
732 : | ian | 44 | if ((iteam == g_CSTeamiNumbers[g_menuOption[id] % (g_cstrike ? 3 : 2)]) || (access(i, ADMIN_IMMUNITY) && i != id)) |
733 : | ian | 1 | { |
734 : | ++b | ||
735 : | |||
736 : | if (g_coloredMenus) | ||
737 : | len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team) | ||
738 : | else | ||
739 : | len += format(menuBody[len], 511-len, "#. %s %s^n", name, team) | ||
740 : | } else { | ||
741 : | keys |= (1<<b) | ||
742 : | |||
743 : | if (is_user_admin(i)) | ||
744 : | len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*\y\R%s^n\w" : "%d. %s * %s^n", ++b, name, team) | ||
745 : | else | ||
746 : | len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++b, name, team) | ||
747 : | } | ||
748 : | } | ||
749 : | |||
750 : | ian | 17 | len += format(menuBody[len], 511-len, "^n8. %L^n", id, "TRANSF_TO", g_CSTeamNames[g_menuOption[id] % (g_cstrike ? 3 : 2)]) |
751 : | ian | 1 | |
752 : | if (end != g_menuPlayersNum[id]) | ||
753 : | { | ||
754 : | format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") | ||
755 : | keys |= MENU_KEY_9 | ||
756 : | } | ||
757 : | else | ||
758 : | format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT") | ||
759 : | |||
760 : | show_menu(id, keys, menuBody, -1, "Team Menu") | ||
761 : | } | ||
762 : | |||
763 : | public cmdTeamMenu(id, level, cid) | ||
764 : | { | ||
765 : | if (!cmd_access(id, level, cid, 1)) | ||
766 : | return PLUGIN_HANDLED | ||
767 : | |||
768 : | g_menuOption[id] = 0 | ||
769 : | |||
770 : | displayTeamMenu(id, g_menuPosition[id] = 0) | ||
771 : | |||
772 : | return PLUGIN_HANDLED | ||
773 : | } | ||
774 : | |||
775 : | /* Client cmds menu */ | ||
776 : | |||
777 : | public actionClcmdMenu(id, key) | ||
778 : | { | ||
779 : | switch (key) | ||
780 : | { | ||
781 : | case 7: | ||
782 : | { | ||
783 : | ++g_menuOption[id] | ||
784 : | g_menuOption[id] %= g_menuSelectNum[id] | ||
785 : | displayClcmdMenu(id, g_menuPosition[id]) | ||
786 : | } | ||
787 : | case 8: displayClcmdMenu(id, ++g_menuPosition[id]) | ||
788 : | case 9: displayClcmdMenu(id, --g_menuPosition[id]) | ||
789 : | default: | ||
790 : | { | ||
791 : | new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] | ||
792 : | new flags = g_clcmdMisc[g_menuSelect[id][g_menuOption[id]]][1] | ||
793 : | |||
794 : | if (is_user_connected(player)) | ||
795 : | { | ||
796 : | ian | 17 | new command[512], authid[32], name[32], userid[32] |
797 : | ian | 1 | |
798 : | ian | 17 | copy(command, charsmax(command), g_clcmdCmd[g_menuSelect[id][g_menuOption[id]]]) |
799 : | ian | 1 | get_user_authid(player, authid, 31) |
800 : | get_user_name(player, name, 31) | ||
801 : | num_to_str(get_user_userid(player), userid, 31) | ||
802 : | |||
803 : | ian | 17 | replace(command, charsmax(command), "%userid%", userid) |
804 : | replace(command, charsmax(command), "%authid%", authid) | ||
805 : | replace(command, charsmax(command), "%name%", name) | ||
806 : | ian | 1 | |
807 : | if (flags & 1) | ||
808 : | { | ||
809 : | server_cmd("%s", command) | ||
810 : | server_exec() | ||
811 : | } else if (flags & 2) | ||
812 : | client_cmd(id, "%s", command) | ||
813 : | else if (flags & 4) | ||
814 : | client_cmd(player, "%s", command) | ||
815 : | } | ||
816 : | |||
817 : | if (flags & 8) | ||
818 : | displayClcmdMenu(id, g_menuPosition[id]) | ||
819 : | } | ||
820 : | } | ||
821 : | |||
822 : | return PLUGIN_HANDLED | ||
823 : | } | ||
824 : | |||
825 : | displayClcmdMenu(id, pos) | ||
826 : | { | ||
827 : | if (pos < 0) | ||
828 : | return | ||
829 : | |||
830 : | get_players(g_menuPlayers[id], g_menuPlayersNum[id]) | ||
831 : | |||
832 : | new menuBody[512] | ||
833 : | new b = 0 | ||
834 : | new i | ||
835 : | new name[32] | ||
836 : | new start = pos * 7 | ||
837 : | |||
838 : | if (start >= g_menuPlayersNum[id]) | ||
839 : | start = pos = g_menuPosition[id] = 0 | ||
840 : | |||
841 : | new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "CL_CMD_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) | ||
842 : | new end = start + 7 | ||
843 : | new keys = MENU_KEY_0|MENU_KEY_8 | ||
844 : | |||
845 : | if (end > g_menuPlayersNum[id]) | ||
846 : | end = g_menuPlayersNum[id] | ||
847 : | |||
848 : | for (new a = start; a < end; ++a) | ||
849 : | { | ||
850 : | i = g_menuPlayers[id][a] | ||
851 : | get_user_name(i, name, 31) | ||
852 : | |||
853 : | ian | 44 | if (!g_menuSelectNum[id] || (access(i, ADMIN_IMMUNITY) && i != id)) |
854 : | ian | 1 | { |
855 : | ++b | ||
856 : | |||
857 : | if (g_coloredMenus) | ||
858 : | len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) | ||
859 : | else | ||
860 : | len += format(menuBody[len], 511-len, "#. %s^n", name) | ||
861 : | } else { | ||
862 : | keys |= (1<<b) | ||
863 : | |||
864 : | if (is_user_admin(i)) | ||
865 : | len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name) | ||
866 : | else | ||
867 : | len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name) | ||
868 : | } | ||
869 : | } | ||
870 : | |||
871 : | if (g_menuSelectNum[id]) | ||
872 : | len += format(menuBody[len], 511-len, "^n8. %s^n", g_clcmdName[g_menuSelect[id][g_menuOption[id]]]) | ||
873 : | else | ||
874 : | len += format(menuBody[len], 511-len, "^n8. %L^n", id, "NO_CMDS") | ||
875 : | |||
876 : | if (end != g_menuPlayersNum[id]) | ||
877 : | { | ||
878 : | format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") | ||
879 : | keys |= MENU_KEY_9 | ||
880 : | } | ||
881 : | else | ||
882 : | format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT") | ||
883 : | |||
884 : | show_menu(id, keys, menuBody, -1, "Client Cmds Menu") | ||
885 : | } | ||
886 : | |||
887 : | public cmdClcmdMenu(id, level, cid) | ||
888 : | { | ||
889 : | if (!cmd_access(id, level, cid, 1)) | ||
890 : | return PLUGIN_HANDLED | ||
891 : | |||
892 : | g_menuSelectNum[id] = 0 | ||
893 : | |||
894 : | for (new a = 0; a < g_clcmdNum; ++a) | ||
895 : | ian | 17 | if (access(id, g_clcmdMisc[a][0])) |
896 : | ian | 1 | g_menuSelect[id][g_menuSelectNum[id]++] = a |
897 : | |||
898 : | g_menuOption[id] = 0 | ||
899 : | |||
900 : | displayClcmdMenu(id, g_menuPosition[id] = 0) | ||
901 : | |||
902 : | return PLUGIN_HANDLED | ||
903 : | } | ||
904 : | |||
905 : | load_settings(szFilename[]) | ||
906 : | { | ||
907 : | if (!file_exists(szFilename)) | ||
908 : | return 0 | ||
909 : | |||
910 : | new text[256], szFlags[32], szAccess[32] | ||
911 : | new a, pos = 0 | ||
912 : | |||
913 : | while (g_clcmdNum < MAX_CLCMDS && read_file(szFilename, pos++, text, 255, a)) | ||
914 : | { | ||
915 : | if (text[0] == ';') continue | ||
916 : | |||
917 : | if (parse(text, g_clcmdName[g_clcmdNum], 31, g_clcmdCmd[g_clcmdNum], 63, szFlags, 31, szAccess, 31) > 3) | ||
918 : | { | ||
919 : | while (replace(g_clcmdCmd[g_clcmdNum], 63, "\'", "^"")) | ||
920 : | { | ||
921 : | // do nothing | ||
922 : | } | ||
923 : | |||
924 : | g_clcmdMisc[g_clcmdNum][1] = read_flags(szFlags) | ||
925 : | g_clcmdMisc[g_clcmdNum][0] = read_flags(szAccess) | ||
926 : | g_clcmdNum++ | ||
927 : | } | ||
928 : | } | ||
929 : | |||
930 : | return 1 | ||
931 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |