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

Annotation of /plmenu.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (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 :     public plugin_natives()
62 :     {
63 :     set_module_filter("module_filter")
64 :     set_native_filter("native_filter")
65 :     }
66 :    
67 :     public plugin_init()
68 :     {
69 :     register_plugin("Players Menu", AMXX_VERSION_STR, "AMXX Dev Team")
70 :     register_dictionary("common.txt")
71 :     register_dictionary("admincmd.txt")
72 :     register_dictionary("plmenu.txt")
73 :    
74 :     register_clcmd("amx_kickmenu", "cmdKickMenu", ADMIN_KICK, "- displays kick menu")
75 :     register_clcmd("amx_banmenu", "cmdBanMenu", ADMIN_BAN, "- displays ban menu")
76 :     register_clcmd("amx_slapmenu", "cmdSlapMenu", ADMIN_SLAY, "- displays slap/slay menu")
77 :     register_clcmd("amx_teammenu", "cmdTeamMenu", ADMIN_LEVEL_A, "- displays team menu")
78 :     register_clcmd("amx_clcmdmenu", "cmdClcmdMenu", ADMIN_LEVEL_A, "- displays client cmds menu")
79 :    
80 :     register_menucmd(register_menuid("Ban Menu"), 1023, "actionBanMenu")
81 :     register_menucmd(register_menuid("Kick Menu"), 1023, "actionKickMenu")
82 :     register_menucmd(register_menuid("Slap/Slay Menu"), 1023, "actionSlapMenu")
83 :     register_menucmd(register_menuid("Team Menu"), 1023, "actionTeamMenu")
84 :     register_menucmd(register_menuid("Client Cmds Menu"), 1023, "actionClcmdMenu")
85 :    
86 :     g_coloredMenus = colored_menus()
87 :    
88 :     new clcmds_ini_file[64]
89 :     get_configsdir(clcmds_ini_file, 63)
90 :     format(clcmds_ini_file, 63, "%s/clcmds.ini", clcmds_ini_file)
91 :     load_settings(clcmds_ini_file)
92 :    
93 :     if (module_exists("cstrike"))
94 :     g_cstrike = 1
95 :     }
96 :    
97 :     public module_filter(const module[])
98 :     {
99 :     if (equali(module, "cstrike"))
100 :     return PLUGIN_HANDLED
101 :    
102 :     return PLUGIN_CONTINUE
103 :     }
104 :    
105 :     public native_filter(const name[], index, trap)
106 :     {
107 :     if (!trap)
108 :     return PLUGIN_HANDLED
109 :    
110 :     return PLUGIN_CONTINUE
111 :     }
112 :    
113 :     /* Ban menu */
114 :    
115 :     public actionBanMenu(id, key)
116 :     {
117 :     switch (key)
118 :     {
119 :     case 7:
120 :     {
121 :     /* BEGIN OF CHANGES BY MISTAGEE ADDED A FEW MORE OPTIONS */
122 :    
123 :     ++g_menuOption[id]
124 :     g_menuOption[id] %= 7
125 :    
126 :     switch (g_menuOption[id])
127 :     {
128 :     case 0: g_menuSettings[id] = 0
129 :     case 1: g_menuSettings[id] = 5
130 :     case 2: g_menuSettings[id] = 10
131 :     case 3: g_menuSettings[id] = 15
132 :     case 4: g_menuSettings[id] = 30
133 :     case 5: g_menuSettings[id] = 45
134 :     case 6: g_menuSettings[id] = 60
135 :     }
136 :    
137 :     displayBanMenu(id, g_menuPosition[id])
138 :     }
139 :     case 8: displayBanMenu(id, ++g_menuPosition[id])
140 :     case 9: displayBanMenu(id, --g_menuPosition[id])
141 :     default:
142 :     {
143 :     new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
144 :     new name[32], name2[32], authid[32], authid2[32]
145 :    
146 :     get_user_name(player, name2, 31)
147 :     get_user_authid(id, authid, 31)
148 :     get_user_authid(player, authid2, 31)
149 :     get_user_name(id, name, 31)
150 :    
151 :     new userid2 = get_user_userid(player)
152 :    
153 :     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])
154 :    
155 :     switch (get_cvar_num("amx_show_activity"))
156 :     {
157 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_BAN_2", name, name2)
158 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_BAN_1", name2)
159 :     }
160 :    
161 :     /* ---------- check for Steam ID added by MistaGee --------------------
162 :     IF AUTHID == 4294967295 OR VALVE_ID_LAN OR HLTV, BAN PER IP TO NOT BAN EVERYONE */
163 :    
164 :     if (equal("4294967295", authid2)
165 :     || equal("HLTV", authid2)
166 :     || equal("STEAM_ID_LAN", authid2)
167 :     || equali("VALVE_ID_LAN", authid2))
168 :     {
169 :     /* END OF MODIFICATIONS BY MISTAGEE */
170 :     new ipa[32]
171 :     get_user_ip(player, ipa, 31, 1)
172 :    
173 :     server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa)
174 :     }
175 :     else
176 :     server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2)
177 :    
178 :     server_exec()
179 :    
180 :     displayBanMenu(id, g_menuPosition[id])
181 :     }
182 :     }
183 :    
184 :     return PLUGIN_HANDLED
185 :     }
186 :    
187 :     displayBanMenu(id, pos)
188 :     {
189 :     if (pos < 0)
190 :     return
191 :    
192 :     get_players(g_menuPlayers[id], g_menuPlayersNum[id])
193 :    
194 :     new menuBody[512]
195 :     new b = 0
196 :     new i
197 :     new name[32]
198 :     new start = pos * 7
199 :    
200 :     if (start >= g_menuPlayersNum[id])
201 :     start = pos = g_menuPosition[id] = 0
202 :    
203 :     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)))
204 :     new end = start + 7
205 :     new keys = MENU_KEY_0|MENU_KEY_8
206 :    
207 :     if (end > g_menuPlayersNum[id])
208 :     end = g_menuPlayersNum[id]
209 :    
210 :     for (new a = start; a < end; ++a)
211 :     {
212 :     i = g_menuPlayers[id][a]
213 :     get_user_name(i, name, 31)
214 :    
215 :     if (is_user_bot(i) || access(i, ADMIN_IMMUNITY))
216 :     {
217 :     ++b
218 :    
219 :     if (g_coloredMenus)
220 :     len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
221 :     else
222 :     len += format(menuBody[len], 511-len, "#. %s^n", name)
223 :     } else {
224 :     keys |= (1<<b)
225 :    
226 :     if (is_user_admin(i))
227 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
228 :     else
229 :     len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
230 :     }
231 :     }
232 :    
233 :     if (g_menuSettings[id])
234 :     len += format(menuBody[len], 511-len, "^n8. %L^n", id, "BAN_FOR_MIN", g_menuSettings[id])
235 :     else
236 :     len += format(menuBody[len], 511-len, "^n8. %L^n", id, "BAN_PERM")
237 :    
238 :     if (end != g_menuPlayersNum[id])
239 :     {
240 :     format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
241 :     keys |= MENU_KEY_9
242 :     }
243 :     else
244 :     format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
245 :    
246 :     show_menu(id, keys, menuBody, -1, "Ban Menu")
247 :     }
248 :    
249 :     public cmdBanMenu(id, level, cid)
250 :     {
251 :     if (!cmd_access(id, level, cid, 1))
252 :     return PLUGIN_HANDLED
253 :    
254 :     g_menuOption[id] = 1
255 :     g_menuSettings[id] = 5
256 :     displayBanMenu(id, g_menuPosition[id] = 0)
257 :    
258 :     return PLUGIN_HANDLED
259 :     }
260 :    
261 :     /* Slap/Slay */
262 :    
263 :     public actionSlapMenu(id, key)
264 :     {
265 :     switch (key)
266 :     {
267 :     case 7:
268 :     {
269 :     ++g_menuOption[id]
270 :     g_menuOption[id] %= 4
271 :    
272 :     switch (g_menuOption[id])
273 :     {
274 :     case 1: g_menuSettings[id] = 0
275 :     case 2: g_menuSettings[id] = 1
276 :     case 3: g_menuSettings[id] = 5
277 :     }
278 :    
279 :     displaySlapMenu(id, g_menuPosition[id])
280 :     }
281 :     case 8: displaySlapMenu(id, ++g_menuPosition[id])
282 :     case 9: displaySlapMenu(id, --g_menuPosition[id])
283 :     default:
284 :     {
285 :     new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
286 :     new name2[32]
287 :    
288 :     get_user_name(player, name2, 31)
289 :    
290 :     if (!is_user_alive(player))
291 :     {
292 :     client_print(id, print_chat, "%L", id, "CANT_PERF_DEAD", name2)
293 :     displaySlapMenu(id, g_menuPosition[id])
294 :     return PLUGIN_HANDLED
295 :     }
296 :    
297 :     new authid[32], authid2[32], name[32]
298 :    
299 :     get_user_authid(id, authid, 31)
300 :     get_user_authid(player, authid2, 31)
301 :     get_user_name(id, name, 31)
302 :    
303 :     if (g_menuOption[id])
304 :     {
305 :     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)
306 :    
307 :     switch (get_cvar_num("amx_show_activity"))
308 :     {
309 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAP_2", name, name2, g_menuSettings[id])
310 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAP_1", name2, g_menuSettings[id])
311 :     }
312 :     } else {
313 :     log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
314 :    
315 :     switch (get_cvar_num("amx_show_activity"))
316 :     {
317 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAY_2", name, name2)
318 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAY_1", name2)
319 :     }
320 :     }
321 :    
322 :     if (g_menuOption[id])
323 :     user_slap(player, (get_user_health(player) > g_menuSettings[id]) ? g_menuSettings[id] : 0)
324 :     else
325 :     user_kill(player)
326 :    
327 :     displaySlapMenu(id, g_menuPosition[id])
328 :     }
329 :     }
330 :    
331 :     return PLUGIN_HANDLED
332 :     }
333 :    
334 :     displaySlapMenu(id, pos)
335 :     {
336 :     if (pos < 0)
337 :     return
338 :    
339 :     get_players(g_menuPlayers[id], g_menuPlayersNum[id])
340 :    
341 :     new menuBody[512]
342 :     new b = 0
343 :     new i
344 :     new name[32], team[4]
345 :     new start = pos * 7
346 :    
347 :     if (start >= g_menuPlayersNum[id])
348 :     start = pos = g_menuPosition[id] = 0
349 :    
350 :     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)))
351 :     new end = start + 7
352 :     new keys = MENU_KEY_0|MENU_KEY_8
353 :    
354 :     if (end > g_menuPlayersNum[id])
355 :     end = g_menuPlayersNum[id]
356 :    
357 :     for (new a = start; a < end; ++a)
358 :     {
359 :     i = g_menuPlayers[id][a]
360 :     get_user_name(i, name, 31)
361 :    
362 :     if (g_cstrike)
363 :     {
364 :     if (cs_get_user_team(i) == CS_TEAM_T)
365 :     {
366 :     copy(team, 3, "TE")
367 :     }
368 :     else if (cs_get_user_team(i) == CS_TEAM_CT)
369 :     {
370 :     copy(team, 3, "CT")
371 :     } else {
372 :     get_user_team(i, team, 3)
373 :     }
374 :     } else {
375 :     get_user_team(i, team, 3)
376 :     }
377 :    
378 :     if (!is_user_alive(i) || access(i, ADMIN_IMMUNITY))
379 :     {
380 :     ++b
381 :    
382 :     if (g_coloredMenus)
383 :     len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team)
384 :     else
385 :     len += format(menuBody[len], 511-len, "#. %s %s^n", name, team)
386 :     } else {
387 :     keys |= (1<<b)
388 :    
389 :     if (is_user_admin(i))
390 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*\y\R%s^n\w" : "%d. %s * %s^n", ++b, name, team)
391 :     else
392 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++b, name, team)
393 :     }
394 :     }
395 :    
396 :     if (g_menuOption[id])
397 :     len += format(menuBody[len], 511-len, "^n8. %L^n", id, "SLAP_WITH_DMG", g_menuSettings[id])
398 :     else
399 :     len += format(menuBody[len], 511-len, "^n8. %L^n", id, "SLAY")
400 :    
401 :     if (end != g_menuPlayersNum[id])
402 :     {
403 :     format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
404 :     keys |= MENU_KEY_9
405 :     }
406 :     else
407 :     format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
408 :    
409 :     show_menu(id, keys, menuBody, -1, "Slap/Slay Menu")
410 :     }
411 :    
412 :     public cmdSlapMenu(id, level, cid)
413 :     {
414 :     if (!cmd_access(id, level, cid, 1))
415 :     return PLUGIN_HANDLED
416 :    
417 :     g_menuOption[id] = 0
418 :     g_menuSettings[id] = 0
419 :    
420 :     displaySlapMenu(id, g_menuPosition[id] = 0)
421 :    
422 :     return PLUGIN_HANDLED
423 :     }
424 :    
425 :     /* Kick */
426 :    
427 :     public actionKickMenu(id, key)
428 :     {
429 :     switch (key)
430 :     {
431 :     case 8: displayKickMenu(id, ++g_menuPosition[id])
432 :     case 9: displayKickMenu(id, --g_menuPosition[id])
433 :     default:
434 :     {
435 :     new player = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
436 :     new authid[32], authid2[32], name[32], name2[32]
437 :    
438 :     get_user_authid(id, authid, 31)
439 :     get_user_authid(player, authid2, 31)
440 :     get_user_name(id, name, 31)
441 :     get_user_name(player, name2, 31)
442 :    
443 :     new userid2 = get_user_userid(player)
444 :    
445 :     log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, userid2, authid2)
446 :    
447 :     switch (get_cvar_num("amx_show_activity"))
448 :     {
449 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_KICK_2", name, name2)
450 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_KICK_1", name2)
451 :     }
452 :    
453 :     server_cmd("kick #%d", userid2)
454 :     server_exec()
455 :    
456 :     displayKickMenu(id, g_menuPosition[id])
457 :     }
458 :     }
459 :    
460 :     return PLUGIN_HANDLED
461 :     }
462 :    
463 :     displayKickMenu(id, pos)
464 :     {
465 :     if (pos < 0)
466 :     return
467 :    
468 :     get_players(g_menuPlayers[id], g_menuPlayersNum[id])
469 :    
470 :     new menuBody[512]
471 :     new b = 0
472 :     new i
473 :     new name[32]
474 :     new start = pos * 8
475 :    
476 :     if (start >= g_menuPlayersNum[id])
477 :     start = pos = g_menuPosition[id] = 0
478 :    
479 :     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)))
480 :     new end = start + 8
481 :     new keys = MENU_KEY_0
482 :    
483 :     if (end > g_menuPlayersNum[id])
484 :     end = g_menuPlayersNum[id]
485 :    
486 :     for (new a = start; a < end; ++a)
487 :     {
488 :     i = g_menuPlayers[id][a]
489 :     get_user_name(i, name, 31)
490 :    
491 :     if (access(i, ADMIN_IMMUNITY))
492 :     {
493 :     ++b
494 :    
495 :     if (g_coloredMenus)
496 :     len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
497 :     else
498 :     len += format(menuBody[len], 511-len, "#. %s^n", name)
499 :     } else {
500 :     keys |= (1<<b)
501 :    
502 :     if (is_user_admin(i))
503 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
504 :     else
505 :     len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
506 :     }
507 :     }
508 :    
509 :     if (end != g_menuPlayersNum[id])
510 :     {
511 :     format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
512 :     keys |= MENU_KEY_9
513 :     }
514 :     else
515 :     format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
516 :    
517 :     show_menu(id, keys, menuBody, -1, "Kick Menu")
518 :     }
519 :    
520 :     public cmdKickMenu(id, level, cid)
521 :     {
522 :     if (cmd_access(id, level, cid, 1))
523 :     displayKickMenu(id, g_menuPosition[id] = 0)
524 :    
525 :     return PLUGIN_HANDLED
526 :     }
527 :    
528 :     /* Team menu */
529 :    
530 :     public actionTeamMenu(id, key)
531 :     {
532 :     switch (key)
533 :     {
534 :     case 7:
535 :     {
536 :     g_menuOption[id] = 1 - g_menuOption[id]
537 :     displayTeamMenu(id, g_menuPosition[id])
538 :     }
539 :     case 8: displayTeamMenu(id, ++g_menuPosition[id])
540 :     case 9: displayTeamMenu(id, --g_menuPosition[id])
541 :     default:
542 :     {
543 :     new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
544 :     new authid[32], authid2[32], name[32], name2[32]
545 :    
546 :     get_user_name(player, name2, 31)
547 :     get_user_authid(id, authid, 31)
548 :     get_user_authid(player, authid2, 31)
549 :     get_user_name(id, name, 31)
550 :    
551 :     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")
552 :    
553 :     switch (get_cvar_num("amx_show_activity"))
554 :     {
555 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_TRANSF_2", name, name2, g_menuOption[id] ? "TERRORIST" : "CT")
556 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_TRANSF_1", name2, g_menuOption[id] ? "TERRORIST" : "CT")
557 :     }
558 :    
559 :     if (g_cstrike)
560 :     {
561 :     if (is_user_alive(player))
562 :     {
563 :     new deaths = cs_get_user_deaths(player)
564 :     user_kill(player, 1)
565 :     cs_set_user_deaths(player, deaths)
566 :     }
567 :     cs_set_user_team(player, g_menuOption[id] ? 1 : 2)
568 :     cs_reset_user_model(player)
569 :     } else {
570 :     new limit_setting = get_cvar_num("mp_limitteams")
571 :    
572 :     set_cvar_num("mp_limitteams", 0)
573 :     engclient_cmd(player, "jointeam", g_menuOption[id] ? "1" : "2")
574 :     engclient_cmd(player, "joinclass", "1")
575 :     set_cvar_num("mp_limitteams", limit_setting)
576 :     }
577 :    
578 :     displayTeamMenu(id, g_menuPosition[id])
579 :     }
580 :     }
581 :    
582 :     return PLUGIN_HANDLED
583 :     }
584 :    
585 :     displayTeamMenu(id, pos)
586 :     {
587 :     if (pos < 0)
588 :     return
589 :    
590 :     get_players(g_menuPlayers[id], g_menuPlayersNum[id])
591 :    
592 :     new menuBody[512]
593 :     new b = 0
594 :     new i, iteam
595 :     new name[32], team[4]
596 :     new start = pos * 7
597 :    
598 :     if (start >= g_menuPlayersNum[id])
599 :     start = pos = g_menuPosition[id] = 0
600 :    
601 :     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)))
602 :     new end = start + 7
603 :     new keys = MENU_KEY_0|MENU_KEY_8
604 :    
605 :     if (end > g_menuPlayersNum[id])
606 :     end = g_menuPlayersNum[id]
607 :    
608 :     for (new a = start; a < end; ++a)
609 :     {
610 :     i = g_menuPlayers[id][a]
611 :     get_user_name(i, name, 31)
612 :    
613 :     if (g_cstrike)
614 :     {
615 :     iteam = _:cs_get_user_team(i)
616 :    
617 :     if (iteam == 1)
618 :     {
619 :     copy(team, 3, "TE")
620 :     }
621 :     else if (iteam == 2)
622 :     {
623 :     copy(team, 3, "CT")
624 :     } else {
625 :     get_user_team(i, team, 3)
626 :     }
627 :     } else {
628 :     iteam = get_user_team(i, team, 3)
629 :     }
630 :    
631 :     if ((iteam == (g_menuOption[id] ? 1 : 2)) || access(i, ADMIN_IMMUNITY))
632 :     {
633 :     ++b
634 :    
635 :     if (g_coloredMenus)
636 :     len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team)
637 :     else
638 :     len += format(menuBody[len], 511-len, "#. %s %s^n", name, team)
639 :     } else {
640 :     keys |= (1<<b)
641 :    
642 :     if (is_user_admin(i))
643 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*\y\R%s^n\w" : "%d. %s * %s^n", ++b, name, team)
644 :     else
645 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++b, name, team)
646 :     }
647 :     }
648 :    
649 :     len += format(menuBody[len], 511-len, "^n8. %L^n", id, "TRANSF_TO", g_menuOption[id] ? "TERRORIST" : "CT")
650 :    
651 :     if (end != g_menuPlayersNum[id])
652 :     {
653 :     format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
654 :     keys |= MENU_KEY_9
655 :     }
656 :     else
657 :     format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
658 :    
659 :     show_menu(id, keys, menuBody, -1, "Team Menu")
660 :     }
661 :    
662 :     public cmdTeamMenu(id, level, cid)
663 :     {
664 :     if (!cmd_access(id, level, cid, 1))
665 :     return PLUGIN_HANDLED
666 :    
667 :     g_menuOption[id] = 0
668 :    
669 :     displayTeamMenu(id, g_menuPosition[id] = 0)
670 :    
671 :     return PLUGIN_HANDLED
672 :     }
673 :    
674 :     /* Client cmds menu */
675 :    
676 :     public actionClcmdMenu(id, key)
677 :     {
678 :     switch (key)
679 :     {
680 :     case 7:
681 :     {
682 :     ++g_menuOption[id]
683 :     g_menuOption[id] %= g_menuSelectNum[id]
684 :     displayClcmdMenu(id, g_menuPosition[id])
685 :     }
686 :     case 8: displayClcmdMenu(id, ++g_menuPosition[id])
687 :     case 9: displayClcmdMenu(id, --g_menuPosition[id])
688 :     default:
689 :     {
690 :     new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
691 :     new flags = g_clcmdMisc[g_menuSelect[id][g_menuOption[id]]][1]
692 :    
693 :     if (is_user_connected(player))
694 :     {
695 :     new command[64], authid[32], name[32], userid[32]
696 :    
697 :     copy(command, 63, g_clcmdCmd[g_menuSelect[id][g_menuOption[id]]])
698 :     get_user_authid(player, authid, 31)
699 :     get_user_name(player, name, 31)
700 :     num_to_str(get_user_userid(player), userid, 31)
701 :    
702 :     replace(command, 63, "%userid%", userid)
703 :     replace(command, 63, "%authid%", authid)
704 :     replace(command, 63, "%name%", name)
705 :    
706 :     if (flags & 1)
707 :     {
708 :     server_cmd("%s", command)
709 :     server_exec()
710 :     } else if (flags & 2)
711 :     client_cmd(id, "%s", command)
712 :     else if (flags & 4)
713 :     client_cmd(player, "%s", command)
714 :     }
715 :    
716 :     if (flags & 8)
717 :     displayClcmdMenu(id, g_menuPosition[id])
718 :     }
719 :     }
720 :    
721 :     return PLUGIN_HANDLED
722 :     }
723 :    
724 :     displayClcmdMenu(id, pos)
725 :     {
726 :     if (pos < 0)
727 :     return
728 :    
729 :     get_players(g_menuPlayers[id], g_menuPlayersNum[id])
730 :    
731 :     new menuBody[512]
732 :     new b = 0
733 :     new i
734 :     new name[32]
735 :     new start = pos * 7
736 :    
737 :     if (start >= g_menuPlayersNum[id])
738 :     start = pos = g_menuPosition[id] = 0
739 :    
740 :     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)))
741 :     new end = start + 7
742 :     new keys = MENU_KEY_0|MENU_KEY_8
743 :    
744 :     if (end > g_menuPlayersNum[id])
745 :     end = g_menuPlayersNum[id]
746 :    
747 :     for (new a = start; a < end; ++a)
748 :     {
749 :     i = g_menuPlayers[id][a]
750 :     get_user_name(i, name, 31)
751 :    
752 :     if (!g_menuSelectNum[id] || access(i, ADMIN_IMMUNITY))
753 :     {
754 :     ++b
755 :    
756 :     if (g_coloredMenus)
757 :     len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
758 :     else
759 :     len += format(menuBody[len], 511-len, "#. %s^n", name)
760 :     } else {
761 :     keys |= (1<<b)
762 :    
763 :     if (is_user_admin(i))
764 :     len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
765 :     else
766 :     len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
767 :     }
768 :     }
769 :    
770 :     if (g_menuSelectNum[id])
771 :     len += format(menuBody[len], 511-len, "^n8. %s^n", g_clcmdName[g_menuSelect[id][g_menuOption[id]]])
772 :     else
773 :     len += format(menuBody[len], 511-len, "^n8. %L^n", id, "NO_CMDS")
774 :    
775 :     if (end != g_menuPlayersNum[id])
776 :     {
777 :     format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
778 :     keys |= MENU_KEY_9
779 :     }
780 :     else
781 :     format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
782 :    
783 :     show_menu(id, keys, menuBody, -1, "Client Cmds Menu")
784 :     }
785 :    
786 :     public cmdClcmdMenu(id, level, cid)
787 :     {
788 :     if (!cmd_access(id, level, cid, 1))
789 :     return PLUGIN_HANDLED
790 :    
791 :     new flags = get_user_flags(id)
792 :    
793 :     g_menuSelectNum[id] = 0
794 :    
795 :     for (new a = 0; a < g_clcmdNum; ++a)
796 :     if (g_clcmdMisc[a][0] & flags)
797 :     g_menuSelect[id][g_menuSelectNum[id]++] = a
798 :    
799 :     g_menuOption[id] = 0
800 :    
801 :     displayClcmdMenu(id, g_menuPosition[id] = 0)
802 :    
803 :     return PLUGIN_HANDLED
804 :     }
805 :    
806 :     load_settings(szFilename[])
807 :     {
808 :     if (!file_exists(szFilename))
809 :     return 0
810 :    
811 :     new text[256], szFlags[32], szAccess[32]
812 :     new a, pos = 0
813 :    
814 :     while (g_clcmdNum < MAX_CLCMDS && read_file(szFilename, pos++, text, 255, a))
815 :     {
816 :     if (text[0] == ';') continue
817 :    
818 :     if (parse(text, g_clcmdName[g_clcmdNum], 31, g_clcmdCmd[g_clcmdNum], 63, szFlags, 31, szAccess, 31) > 3)
819 :     {
820 :     while (replace(g_clcmdCmd[g_clcmdNum], 63, "\'", "^""))
821 :     {
822 :     // do nothing
823 :     }
824 :    
825 :     g_clcmdMisc[g_clcmdNum][1] = read_flags(szFlags)
826 :     g_clcmdMisc[g_clcmdNum][0] = read_flags(szAccess)
827 :     g_clcmdNum++
828 :     }
829 :     }
830 :    
831 :     return 1
832 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4