[Half-Life AMXX] / plmenu.sma Repository:
ViewVC logotype

Annotation of /plmenu.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (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 :     ArrayPushCell(g_slapsettings, 1);
122 :     ArrayPushCell(g_slapsettings, 5);
123 :    
124 :    
125 :     register_srvcmd("amx_plmenu_bantimes", "plmenu_setbantimes");
126 :     register_srvcmd("amx_plmenu_slapdmg", "plmenu_setslapdmg");
127 : ian 1
128 :     g_coloredMenus = colored_menus()
129 :    
130 :     new clcmds_ini_file[64]
131 :     get_configsdir(clcmds_ini_file, 63)
132 :     format(clcmds_ini_file, 63, "%s/clcmds.ini", clcmds_ini_file)
133 :     load_settings(clcmds_ini_file)
134 :    
135 :     if (module_exists("cstrike"))
136 :     g_cstrike = 1
137 :     }
138 : ian 17 public plmenu_setbantimes()
139 :     {
140 :     new buff[32];
141 :     new args = read_argc();
142 :    
143 :     if (args <= 1)
144 :     {
145 :     server_print("usage: amx_plmenu_bantimes <time1> [time2] [time3] ...");
146 :     server_print(" use time of 0 for permanent.");
147 :    
148 :     return;
149 :     }
150 :    
151 :     ArrayClear(g_bantimes);
152 :    
153 :     for (new i = 1; i < args; i++)
154 :     {
155 :     read_argv(i, buff, charsmax(buff));
156 :    
157 :     ArrayPushCell(g_bantimes, str_to_num(buff));
158 :    
159 :     }
160 :    
161 :     }
162 :     public plmenu_setslapdmg()
163 :     {
164 :     new buff[32];
165 :     new args = read_argc();
166 :    
167 :     if (args <= 1)
168 :     {
169 :     server_print("usage: amx_plmenu_slapdmg <dmg1> [dmg2] [dmg3] ...");
170 :     server_print(" slay is automatically set for the first value.");
171 :    
172 :     return;
173 :     }
174 :    
175 :     ArrayClear(g_slapsettings);
176 :    
177 :     ArrayPushCell(g_slapsettings, 0); // compensate for slay
178 :    
179 :     for (new i = 1; i < args; i++)
180 :     {
181 :     read_argv(i, buff, charsmax(buff));
182 :    
183 :     ArrayPushCell(g_slapsettings, str_to_num(buff));
184 :    
185 :     }
186 :    
187 :     }
188 : ian 1 public module_filter(const module[])
189 :     {
190 :     if (equali(module, "cstrike"))
191 :     return PLUGIN_HANDLED
192 :    
193 :     return PLUGIN_CONTINUE
194 :     }
195 :    
196 :     public native_filter(const name[], index, trap)
197 :     {
198 :     if (!trap)
199 :     return PLUGIN_HANDLED
200 :    
201 :     return PLUGIN_CONTINUE
202 :     }
203 :    
204 :     /* Ban menu */
205 :    
206 :     public actionBanMenu(id, key)
207 :     {
208 :     switch (key)
209 :     {
210 :     case 7:
211 :     {
212 :     /* BEGIN OF CHANGES BY MISTAGEE ADDED A FEW MORE OPTIONS */
213 :    
214 :     ++g_menuOption[id]
215 : ian 17 g_menuOption[id] %= ArraySize(g_bantimes);
216 : ian 1
217 : ian 17 g_menuSettings[id] = ArrayGetCell(g_bantimes, g_menuOption[id]);
218 : ian 1
219 :     displayBanMenu(id, g_menuPosition[id])
220 :     }
221 :     case 8: displayBanMenu(id, ++g_menuPosition[id])
222 :     case 9: displayBanMenu(id, --g_menuPosition[id])
223 :     default:
224 :     {
225 :     new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
226 :     new name[32], name2[32], authid[32], authid2[32]
227 :    
228 :     get_user_name(player, name2, 31)
229 :     get_user_authid(id, authid, 31)
230 :     get_user_authid(player, authid2, 31)
231 :     get_user_name(id, name, 31)
232 :    
233 :     new userid2 = get_user_userid(player)
234 :    
235 :     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])
236 :    
237 : ian 17 if (g_menuSettings[id]==0) // permanent
238 : ian 1 {
239 : ian 17 new maxpl = get_maxplayers();
240 :     for (new i = 1; i <= maxpl; i++)
241 :     {
242 :     show_activity_id(i, id, name, "%L %s %L", i, "BAN", name2, i, "PERM");
243 :     }
244 : ian 1 }
245 : ian 17 else
246 :     {
247 :     new tempTime[32];
248 :     formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]);
249 :     new maxpl = get_maxplayers();
250 :     for (new i = 1; i <= maxpl; i++)
251 :     {
252 :     show_activity_id(i, id, name, "%L %s %L", i, "BAN", name2, i, "FOR_MIN", tempTime);
253 :     }
254 :     }
255 : ian 1 /* ---------- check for Steam ID added by MistaGee --------------------
256 :     IF AUTHID == 4294967295 OR VALVE_ID_LAN OR HLTV, BAN PER IP TO NOT BAN EVERYONE */
257 :    
258 :     if (equal("4294967295", authid2)
259 :     || equal("HLTV", authid2)
260 :     || equal("STEAM_ID_LAN", authid2)
261 :     || equali("VALVE_ID_LAN", authid2))
262 :     {
263 :     /* END OF MODIFICATIONS BY MISTAGEE */
264 :     new ipa[32]
265 :     get_user_ip(player, ipa, 31, 1)
266 :    
267 :     server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa)
268 :     }
269 :     else
270 : ian 17 {
271 : ian 1 server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2)
272 : ian 17 }
273 : ian 1
274 :     server_exec()
275 :    
276 :     displayBanMenu(id, g_menuPosition[id])
277 :     }
278 :     }
279 :    
280 :     return PLUGIN_HANDLED
281 :     }
282 :    
283 :     displayBanMenu(id, pos)
284 :     {
285 :     if (pos < 0)
286 :     return
287 :    
288 :     get_players(g_menuPlayers[id], g_menuPlayersNum[id])
289 :    
290 :     new menuBody[512]
291 :     new b = 0
292 :     new i
293 :     new name[32]
294 :     new start = pos * 7
295 :    
296 :     if (start >= g_menuPlayersNum[id])
297 :     start = pos = g_menuPosition[id] = 0
298 :    
299 :     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)))
300 :     new end = start + 7
301 :     new keys = MENU_KEY_0|MENU_KEY_8
302 :    
303 :     if (end > g_menuPlayersNum[id])
304 :     end = g_menuPlayersNum[id]
305 :    
306 :     for (new a = start; a < end; ++a)
307 :     {
308 :     i = g_menuPlayers[id][a]
309 :     get_user_name(i, name, 31)
310 :    
311 :     if (is_user_bot(i) || access(i, ADMIN_IMMUNITY))
312 :     {
313 :     ++b
314 :    
315 :     if (g_coloredMenus)
316 :     len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
317 :     else
318 :     len += format(menuBody[len], 511-len, "#. %s^n", name)
319 :     } else {
320 :     keys |= (1<<b)
321 :    
322 :     if (is_user_admin(i))
323 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
324 :     else
325 :     len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
326 :     }
327 :     }
328 :    
329 :     if (g_menuSettings[id])
330 :     len += format(menuBody[len], 511-len, "^n8. %L^n", id, "BAN_FOR_MIN", g_menuSettings[id])
331 :     else
332 :     len += format(menuBody[len], 511-len, "^n8. %L^n", id, "BAN_PERM")
333 :    
334 :     if (end != g_menuPlayersNum[id])
335 :     {
336 :     format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
337 :     keys |= MENU_KEY_9
338 :     }
339 :     else
340 :     format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
341 :    
342 :     show_menu(id, keys, menuBody, -1, "Ban Menu")
343 :     }
344 :    
345 :     public cmdBanMenu(id, level, cid)
346 :     {
347 :     if (!cmd_access(id, level, cid, 1))
348 :     return PLUGIN_HANDLED
349 :    
350 : ian 17 g_menuOption[id] = 0
351 :    
352 :     if (ArraySize(g_bantimes) > 0)
353 :     {
354 :     g_menuSettings[id] = ArrayGetCell(g_bantimes, g_menuOption[id]);
355 :     }
356 :     else
357 :     {
358 :     // should never happen, but failsafe
359 :     g_menuSettings[id] = 0
360 :     }
361 : ian 1 displayBanMenu(id, g_menuPosition[id] = 0)
362 :    
363 :     return PLUGIN_HANDLED
364 :     }
365 :    
366 :     /* Slap/Slay */
367 :    
368 :     public actionSlapMenu(id, key)
369 :     {
370 :     switch (key)
371 :     {
372 :     case 7:
373 :     {
374 :     ++g_menuOption[id]
375 :    
376 : ian 17 g_menuOption[id] %= ArraySize(g_slapsettings);
377 : ian 1
378 : ian 17 g_menuSettings[id] = ArrayGetCell(g_slapsettings, g_menuOption[id]);
379 :    
380 :     displaySlapMenu(id, g_menuPosition[id]);
381 : ian 1 }
382 :     case 8: displaySlapMenu(id, ++g_menuPosition[id])
383 :     case 9: displaySlapMenu(id, --g_menuPosition[id])
384 :     default:
385 :     {
386 :     new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
387 :     new name2[32]
388 :    
389 :     get_user_name(player, name2, 31)
390 :    
391 :     if (!is_user_alive(player))
392 :     {
393 :     client_print(id, print_chat, "%L", id, "CANT_PERF_DEAD", name2)
394 :     displaySlapMenu(id, g_menuPosition[id])
395 :     return PLUGIN_HANDLED
396 :     }
397 :    
398 :     new authid[32], authid2[32], name[32]
399 :    
400 :     get_user_authid(id, authid, 31)
401 :     get_user_authid(player, authid2, 31)
402 :     get_user_name(id, name, 31)
403 :    
404 :     if (g_menuOption[id])
405 :     {
406 :     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)
407 : ian 17
408 :     show_activity_key("ADMIN_SLAP_1", "ADMIN_SLAP_2", name, name2, g_menuSettings[id]);
409 : ian 1 } else {
410 :     log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
411 :    
412 : ian 17 show_activity_key("ADMIN_SLAY_1", "ADMIN_SLAY_2", name, name2);
413 : ian 1 }
414 :    
415 :     if (g_menuOption[id])
416 :     user_slap(player, (get_user_health(player) > g_menuSettings[id]) ? g_menuSettings[id] : 0)
417 :     else
418 :     user_kill(player)
419 :    
420 :     displaySlapMenu(id, g_menuPosition[id])
421 :     }
422 :     }
423 :    
424 :     return PLUGIN_HANDLED
425 :     }
426 :    
427 :     displaySlapMenu(id, pos)
428 :     {
429 :     if (pos < 0)
430 :     return
431 :    
432 :     get_players(g_menuPlayers[id], g_menuPlayersNum[id])
433 :    
434 :     new menuBody[512]
435 :     new b = 0
436 :     new i
437 :     new name[32], team[4]
438 :     new start = pos * 7
439 :    
440 :     if (start >= g_menuPlayersNum[id])
441 :     start = pos = g_menuPosition[id] = 0
442 :    
443 :     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)))
444 :     new end = start + 7
445 :     new keys = MENU_KEY_0|MENU_KEY_8
446 :    
447 :     if (end > g_menuPlayersNum[id])
448 :     end = g_menuPlayersNum[id]
449 :    
450 :     for (new a = start; a < end; ++a)
451 :     {
452 :     i = g_menuPlayers[id][a]
453 :     get_user_name(i, name, 31)
454 :    
455 :     if (g_cstrike)
456 :     {
457 :     if (cs_get_user_team(i) == CS_TEAM_T)
458 :     {
459 :     copy(team, 3, "TE")
460 :     }
461 :     else if (cs_get_user_team(i) == CS_TEAM_CT)
462 :     {
463 :     copy(team, 3, "CT")
464 :     } else {
465 :     get_user_team(i, team, 3)
466 :     }
467 :     } else {
468 :     get_user_team(i, team, 3)
469 :     }
470 :    
471 :     if (!is_user_alive(i) || access(i, ADMIN_IMMUNITY))
472 :     {
473 :     ++b
474 :    
475 :     if (g_coloredMenus)
476 :     len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team)
477 :     else
478 :     len += format(menuBody[len], 511-len, "#. %s %s^n", name, team)
479 :     } else {
480 :     keys |= (1<<b)
481 :    
482 :     if (is_user_admin(i))
483 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*\y\R%s^n\w" : "%d. %s * %s^n", ++b, name, team)
484 :     else
485 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++b, name, team)
486 :     }
487 :     }
488 :    
489 :     if (g_menuOption[id])
490 :     len += format(menuBody[len], 511-len, "^n8. %L^n", id, "SLAP_WITH_DMG", g_menuSettings[id])
491 :     else
492 :     len += format(menuBody[len], 511-len, "^n8. %L^n", id, "SLAY")
493 :    
494 :     if (end != g_menuPlayersNum[id])
495 :     {
496 :     format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
497 :     keys |= MENU_KEY_9
498 :     }
499 :     else
500 :     format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
501 :    
502 :     show_menu(id, keys, menuBody, -1, "Slap/Slay Menu")
503 :     }
504 :    
505 :     public cmdSlapMenu(id, level, cid)
506 :     {
507 :     if (!cmd_access(id, level, cid, 1))
508 :     return PLUGIN_HANDLED
509 :    
510 :     g_menuOption[id] = 0
511 : ian 17 if (ArraySize(g_slapsettings) > 0)
512 :     {
513 :     g_menuSettings[id] = ArrayGetCell(g_slapsettings, g_menuOption[id]);
514 :     }
515 :     else
516 :     {
517 :     // should never happen, but failsafe
518 :     g_menuSettings[id] = 0
519 :     }
520 : ian 1
521 :     displaySlapMenu(id, g_menuPosition[id] = 0)
522 :    
523 :     return PLUGIN_HANDLED
524 :     }
525 :    
526 :     /* Kick */
527 :    
528 :     public actionKickMenu(id, key)
529 :     {
530 :     switch (key)
531 :     {
532 :     case 8: displayKickMenu(id, ++g_menuPosition[id])
533 :     case 9: displayKickMenu(id, --g_menuPosition[id])
534 :     default:
535 :     {
536 :     new player = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
537 :     new authid[32], authid2[32], name[32], name2[32]
538 :    
539 :     get_user_authid(id, authid, 31)
540 :     get_user_authid(player, authid2, 31)
541 :     get_user_name(id, name, 31)
542 :     get_user_name(player, name2, 31)
543 :    
544 :     new userid2 = get_user_userid(player)
545 :    
546 :     log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, userid2, authid2)
547 :    
548 : ian 17 show_activity_key("ADMIN_KICK_1", "ADMIN_KICK_2", name, name2);
549 : ian 1
550 : ian 17
551 : ian 1 server_cmd("kick #%d", userid2)
552 :     server_exec()
553 :    
554 :     displayKickMenu(id, g_menuPosition[id])
555 :     }
556 :     }
557 :    
558 :     return PLUGIN_HANDLED
559 :     }
560 :    
561 :     displayKickMenu(id, pos)
562 :     {
563 :     if (pos < 0)
564 :     return
565 :    
566 :     get_players(g_menuPlayers[id], g_menuPlayersNum[id])
567 :    
568 :     new menuBody[512]
569 :     new b = 0
570 :     new i
571 :     new name[32]
572 :     new start = pos * 8
573 :    
574 :     if (start >= g_menuPlayersNum[id])
575 :     start = pos = g_menuPosition[id] = 0
576 :    
577 :     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)))
578 :     new end = start + 8
579 :     new keys = MENU_KEY_0
580 :    
581 :     if (end > g_menuPlayersNum[id])
582 :     end = g_menuPlayersNum[id]
583 :    
584 :     for (new a = start; a < end; ++a)
585 :     {
586 :     i = g_menuPlayers[id][a]
587 :     get_user_name(i, name, 31)
588 :    
589 :     if (access(i, ADMIN_IMMUNITY))
590 :     {
591 :     ++b
592 :    
593 :     if (g_coloredMenus)
594 :     len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
595 :     else
596 :     len += format(menuBody[len], 511-len, "#. %s^n", name)
597 :     } else {
598 :     keys |= (1<<b)
599 :    
600 :     if (is_user_admin(i))
601 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
602 :     else
603 :     len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
604 :     }
605 :     }
606 :    
607 :     if (end != g_menuPlayersNum[id])
608 :     {
609 :     format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
610 :     keys |= MENU_KEY_9
611 :     }
612 :     else
613 :     format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
614 :    
615 :     show_menu(id, keys, menuBody, -1, "Kick Menu")
616 :     }
617 :    
618 :     public cmdKickMenu(id, level, cid)
619 :     {
620 :     if (cmd_access(id, level, cid, 1))
621 :     displayKickMenu(id, g_menuPosition[id] = 0)
622 :    
623 :     return PLUGIN_HANDLED
624 :     }
625 :    
626 :     /* Team menu */
627 :    
628 :     public actionTeamMenu(id, key)
629 :     {
630 :     switch (key)
631 :     {
632 :     case 7:
633 :     {
634 : ian 17 g_menuOption[id] = (g_menuOption[id] + 1) % (g_cstrike ? 3 : 2);
635 : ian 1 displayTeamMenu(id, g_menuPosition[id])
636 :     }
637 :     case 8: displayTeamMenu(id, ++g_menuPosition[id])
638 :     case 9: displayTeamMenu(id, --g_menuPosition[id])
639 :     default:
640 :     {
641 :     new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
642 :     new authid[32], authid2[32], name[32], name2[32]
643 :    
644 :     get_user_name(player, name2, 31)
645 :     get_user_authid(id, authid, 31)
646 :     get_user_authid(player, authid2, 31)
647 :     get_user_name(id, name, 31)
648 :    
649 :     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")
650 :    
651 : ian 17 show_activity_key("ADMIN_TRANSF_1", "ADMIN_TRANSF_2", name, name2, g_CSTeamNames[g_menuOption[id] % 3]);
652 : ian 1
653 :     if (g_cstrike)
654 :     {
655 :     if (is_user_alive(player))
656 :     {
657 :     new deaths = cs_get_user_deaths(player)
658 :     user_kill(player, 1)
659 :     cs_set_user_deaths(player, deaths)
660 :     }
661 : ian 17 // This modulo math just aligns the option to the CsTeams-corresponding number
662 :     cs_set_user_team(player, (g_menuOption[id] % 3) + 1)
663 : ian 1 cs_reset_user_model(player)
664 :     } else {
665 :     new limit_setting = get_cvar_num("mp_limitteams")
666 :    
667 :     set_cvar_num("mp_limitteams", 0)
668 : ian 17 engclient_cmd(player, "jointeam", g_CSTeamNumbers[g_menuOption[id] % 2])
669 : ian 1 engclient_cmd(player, "joinclass", "1")
670 :     set_cvar_num("mp_limitteams", limit_setting)
671 :     }
672 :    
673 :     displayTeamMenu(id, g_menuPosition[id])
674 :     }
675 :     }
676 :    
677 :     return PLUGIN_HANDLED
678 :     }
679 :    
680 :     displayTeamMenu(id, pos)
681 :     {
682 :     if (pos < 0)
683 :     return
684 :    
685 :     get_players(g_menuPlayers[id], g_menuPlayersNum[id])
686 :    
687 :     new menuBody[512]
688 :     new b = 0
689 :     new i, iteam
690 :     new name[32], team[4]
691 :     new start = pos * 7
692 :    
693 :     if (start >= g_menuPlayersNum[id])
694 :     start = pos = g_menuPosition[id] = 0
695 :    
696 :     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)))
697 :     new end = start + 7
698 :     new keys = MENU_KEY_0|MENU_KEY_8
699 :    
700 :     if (end > g_menuPlayersNum[id])
701 :     end = g_menuPlayersNum[id]
702 :    
703 :     for (new a = start; a < end; ++a)
704 :     {
705 :     i = g_menuPlayers[id][a]
706 :     get_user_name(i, name, 31)
707 :    
708 :     if (g_cstrike)
709 :     {
710 :     iteam = _:cs_get_user_team(i)
711 :    
712 :     if (iteam == 1)
713 :     {
714 :     copy(team, 3, "TE")
715 :     }
716 :     else if (iteam == 2)
717 :     {
718 :     copy(team, 3, "CT")
719 : ian 17 }
720 :     else if (iteam == 3)
721 :     {
722 :     copy(team, 3, "SPE");
723 :     iteam = 6;
724 : ian 1 } else {
725 : ian 17 iteam = get_user_team(i, team, 3)
726 : ian 1 }
727 :     } else {
728 :     iteam = get_user_team(i, team, 3)
729 :     }
730 :    
731 : ian 17 if ((iteam == g_CSTeamiNumbers[g_menuOption[id] % (g_cstrike ? 3 : 2)]) || access(i, ADMIN_IMMUNITY))
732 : ian 1 {
733 :     ++b
734 :    
735 :     if (g_coloredMenus)
736 :     len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team)
737 :     else
738 :     len += format(menuBody[len], 511-len, "#. %s %s^n", name, team)
739 :     } else {
740 :     keys |= (1<<b)
741 :    
742 :     if (is_user_admin(i))
743 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*\y\R%s^n\w" : "%d. %s * %s^n", ++b, name, team)
744 :     else
745 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++b, name, team)
746 :     }
747 :     }
748 :    
749 : ian 17 len += format(menuBody[len], 511-len, "^n8. %L^n", id, "TRANSF_TO", g_CSTeamNames[g_menuOption[id] % (g_cstrike ? 3 : 2)])
750 : ian 1
751 :     if (end != g_menuPlayersNum[id])
752 :     {
753 :     format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
754 :     keys |= MENU_KEY_9
755 :     }
756 :     else
757 :     format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
758 :    
759 :     show_menu(id, keys, menuBody, -1, "Team Menu")
760 :     }
761 :    
762 :     public cmdTeamMenu(id, level, cid)
763 :     {
764 :     if (!cmd_access(id, level, cid, 1))
765 :     return PLUGIN_HANDLED
766 :    
767 :     g_menuOption[id] = 0
768 :    
769 :     displayTeamMenu(id, g_menuPosition[id] = 0)
770 :    
771 :     return PLUGIN_HANDLED
772 :     }
773 :    
774 :     /* Client cmds menu */
775 :    
776 :     public actionClcmdMenu(id, key)
777 :     {
778 :     switch (key)
779 :     {
780 :     case 7:
781 :     {
782 :     ++g_menuOption[id]
783 :     g_menuOption[id] %= g_menuSelectNum[id]
784 :     displayClcmdMenu(id, g_menuPosition[id])
785 :     }
786 :     case 8: displayClcmdMenu(id, ++g_menuPosition[id])
787 :     case 9: displayClcmdMenu(id, --g_menuPosition[id])
788 :     default:
789 :     {
790 :     new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
791 :     new flags = g_clcmdMisc[g_menuSelect[id][g_menuOption[id]]][1]
792 :    
793 :     if (is_user_connected(player))
794 :     {
795 : ian 17 new command[512], authid[32], name[32], userid[32]
796 : ian 1
797 : ian 17 copy(command, charsmax(command), g_clcmdCmd[g_menuSelect[id][g_menuOption[id]]])
798 : ian 1 get_user_authid(player, authid, 31)
799 :     get_user_name(player, name, 31)
800 :     num_to_str(get_user_userid(player), userid, 31)
801 :    
802 : ian 17 replace(command, charsmax(command), "%userid%", userid)
803 :     replace(command, charsmax(command), "%authid%", authid)
804 :     replace(command, charsmax(command), "%name%", name)
805 : ian 1
806 :     if (flags & 1)
807 :     {
808 :     server_cmd("%s", command)
809 :     server_exec()
810 :     } else if (flags & 2)
811 :     client_cmd(id, "%s", command)
812 :     else if (flags & 4)
813 :     client_cmd(player, "%s", command)
814 :     }
815 :    
816 :     if (flags & 8)
817 :     displayClcmdMenu(id, g_menuPosition[id])
818 :     }
819 :     }
820 :    
821 :     return PLUGIN_HANDLED
822 :     }
823 :    
824 :     displayClcmdMenu(id, pos)
825 :     {
826 :     if (pos < 0)
827 :     return
828 :    
829 :     get_players(g_menuPlayers[id], g_menuPlayersNum[id])
830 :    
831 :     new menuBody[512]
832 :     new b = 0
833 :     new i
834 :     new name[32]
835 :     new start = pos * 7
836 :    
837 :     if (start >= g_menuPlayersNum[id])
838 :     start = pos = g_menuPosition[id] = 0
839 :    
840 :     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)))
841 :     new end = start + 7
842 :     new keys = MENU_KEY_0|MENU_KEY_8
843 :    
844 :     if (end > g_menuPlayersNum[id])
845 :     end = g_menuPlayersNum[id]
846 :    
847 :     for (new a = start; a < end; ++a)
848 :     {
849 :     i = g_menuPlayers[id][a]
850 :     get_user_name(i, name, 31)
851 :    
852 :     if (!g_menuSelectNum[id] || access(i, ADMIN_IMMUNITY))
853 :     {
854 :     ++b
855 :    
856 :     if (g_coloredMenus)
857 :     len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
858 :     else
859 :     len += format(menuBody[len], 511-len, "#. %s^n", name)
860 :     } else {
861 :     keys |= (1<<b)
862 :    
863 :     if (is_user_admin(i))
864 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
865 :     else
866 :     len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
867 :     }
868 :     }
869 :    
870 :     if (g_menuSelectNum[id])
871 :     len += format(menuBody[len], 511-len, "^n8. %s^n", g_clcmdName[g_menuSelect[id][g_menuOption[id]]])
872 :     else
873 :     len += format(menuBody[len], 511-len, "^n8. %L^n", id, "NO_CMDS")
874 :    
875 :     if (end != g_menuPlayersNum[id])
876 :     {
877 :     format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
878 :     keys |= MENU_KEY_9
879 :     }
880 :     else
881 :     format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
882 :    
883 :     show_menu(id, keys, menuBody, -1, "Client Cmds Menu")
884 :     }
885 :    
886 :     public cmdClcmdMenu(id, level, cid)
887 :     {
888 :     if (!cmd_access(id, level, cid, 1))
889 :     return PLUGIN_HANDLED
890 :    
891 :     g_menuSelectNum[id] = 0
892 :    
893 :     for (new a = 0; a < g_clcmdNum; ++a)
894 : ian 17 if (access(id, g_clcmdMisc[a][0]))
895 : ian 1 g_menuSelect[id][g_menuSelectNum[id]++] = a
896 :    
897 :     g_menuOption[id] = 0
898 :    
899 :     displayClcmdMenu(id, g_menuPosition[id] = 0)
900 :    
901 :     return PLUGIN_HANDLED
902 :     }
903 :    
904 :     load_settings(szFilename[])
905 :     {
906 :     if (!file_exists(szFilename))
907 :     return 0
908 :    
909 :     new text[256], szFlags[32], szAccess[32]
910 :     new a, pos = 0
911 :    
912 :     while (g_clcmdNum < MAX_CLCMDS && read_file(szFilename, pos++, text, 255, a))
913 :     {
914 :     if (text[0] == ';') continue
915 :    
916 :     if (parse(text, g_clcmdName[g_clcmdNum], 31, g_clcmdCmd[g_clcmdNum], 63, szFlags, 31, szAccess, 31) > 3)
917 :     {
918 :     while (replace(g_clcmdCmd[g_clcmdNum], 63, "\'", "^""))
919 :     {
920 :     // do nothing
921 :     }
922 :    
923 :     g_clcmdMisc[g_clcmdNum][1] = read_flags(szFlags)
924 :     g_clcmdMisc[g_clcmdNum][0] = read_flags(szAccess)
925 :     g_clcmdNum++
926 :     }
927 :     }
928 :    
929 :     return 1
930 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4