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

Annotation of /admincmd.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : ian 1 /* AMX Mod X
2 :     * Admin Commands 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 :     #define MAXRCONCVARS 16
39 :    
40 :     new g_cvarRcon[MAXRCONCVARS][32]
41 :     new g_cvarRconNum
42 :     new g_pauseCon
43 :     new Float:g_pausAble
44 :     new bool:g_Paused
45 :     new bool:g_PauseAllowed = false
46 :     new g_addCvar[] = "amx_cvar add %s"
47 :    
48 :     public plugin_init()
49 :     {
50 :     register_plugin("Admin Commands", AMXX_VERSION_STR, "AMXX Dev Team")
51 :     register_dictionary("admincmd.txt")
52 :     register_dictionary("common.txt")
53 :     register_concmd("amx_kick", "cmdKick", ADMIN_KICK, "<name or #userid> [reason]")
54 :     register_concmd("amx_ban", "cmdBan", ADMIN_BAN, "<name or #userid> <minutes> [reason]")
55 :     register_concmd("amx_banip", "cmdBanIP", ADMIN_BAN, "<name or #userid> <minutes> [reason]")
56 :     register_concmd("amx_addban", "cmdAddBan", ADMIN_RCON, "<authid or ip> <minutes> [reason]")
57 :     register_concmd("amx_unban", "cmdUnban", ADMIN_BAN, "<authid or ip>")
58 :     register_concmd("amx_slay", "cmdSlay", ADMIN_SLAY, "<name or #userid>")
59 :     register_concmd("amx_slap", "cmdSlap", ADMIN_SLAY, "<name or #userid> [power]")
60 :     register_concmd("amx_leave", "cmdLeave", ADMIN_KICK, "<tag> [tag] [tag] [tag]")
61 :     register_concmd("amx_pause", "cmdPause", ADMIN_CVAR, "- pause or unpause the game")
62 :     register_concmd("amx_who", "cmdWho", ADMIN_ADMIN, "- displays who is on server")
63 :     register_concmd("amx_cvar", "cmdCvar", ADMIN_CVAR, "<cvar> [value]")
64 :     register_concmd("amx_plugins", "cmdPlugins", ADMIN_ADMIN)
65 :     register_concmd("amx_modules", "cmdModules", ADMIN_ADMIN)
66 :     register_concmd("amx_map", "cmdMap", ADMIN_MAP, "<mapname>")
67 :     register_concmd("amx_cfg", "cmdCfg", ADMIN_CFG, "<filename>")
68 :     register_concmd("amx_nick", "cmdNick", ADMIN_SLAY, "<name or #userid> <new nick>")
69 :     register_clcmd("amx_rcon", "cmdRcon", ADMIN_RCON, "<command line>")
70 :     register_clcmd("amx_showrcon", "cmdShowRcon", ADMIN_RCON, "<command line>")
71 :     register_clcmd("pauseAck", "cmdLBack")
72 :     }
73 :    
74 :     public plugin_cfg()
75 :     {
76 :     // Cvars which can be changed only with rcon access
77 :     server_cmd(g_addCvar, "rcon_password")
78 :     server_cmd(g_addCvar, "amx_show_activity")
79 :     server_cmd(g_addCvar, "amx_mode")
80 :     server_cmd(g_addCvar, "amx_password_field")
81 :     server_cmd(g_addCvar, "amx_default_access")
82 :     server_cmd(g_addCvar, "amx_reserved_slots")
83 :     server_cmd(g_addCvar, "amx_reservation")
84 :     server_cmd(g_addCvar, "amx_conmotd_file")
85 :     }
86 :    
87 :     public cmdKick(id, level, cid)
88 :     {
89 :     if (!cmd_access(id, level, cid, 2))
90 :     return PLUGIN_HANDLED
91 :    
92 :     new arg[32]
93 :     read_argv(1, arg, 31)
94 :     new player = cmd_target(id, arg, 1)
95 :    
96 :     if (!player)
97 :     return PLUGIN_HANDLED
98 :    
99 :     new authid[32], authid2[32], name2[32], name[32], userid2, reason[32]
100 :    
101 :     get_user_authid(id, authid, 31)
102 :     get_user_authid(player, authid2, 31)
103 :     get_user_name(player, name2, 31)
104 :     get_user_name(id, name, 31)
105 :     userid2 = get_user_userid(player)
106 :     read_argv(2, reason, 31)
107 :     remove_quotes(reason)
108 :    
109 :     log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^" (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, reason)
110 :    
111 :     switch (get_cvar_num("amx_show_activity"))
112 :     {
113 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_KICK_2", name, name2)
114 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_KICK_1", name2)
115 :     }
116 :    
117 :     if (is_user_bot(player))
118 :     server_cmd("kick #%d", userid2)
119 :     else
120 :     {
121 :     if (reason[0])
122 :     server_cmd("kick #%d ^"%s^"", userid2, reason)
123 :     else
124 :     server_cmd("kick #%d", userid2)
125 :     }
126 :    
127 :     console_print(id, "[AMXX] Client ^"%s^" kicked", name2)
128 :    
129 :     return PLUGIN_HANDLED
130 :     }
131 :    
132 :     public cmdUnban(id, level, cid)
133 :     {
134 :     if (!cmd_access(id, level, cid, 2))
135 :     return PLUGIN_HANDLED
136 :    
137 :     new arg[32], authid[32], name[32]
138 :    
139 :     read_argv(1, arg, 31)
140 :    
141 :     if (contain(arg, ".") != -1)
142 :     {
143 :     server_cmd("removeip ^"%s^";writeip", arg)
144 :     console_print(id, "[AMXX] %L", id, "IP_REMOVED", arg)
145 :     } else {
146 :     server_cmd("removeid %s;writeid", arg)
147 :     console_print(id, "[AMXX] %L", id, "AUTHID_REMOVED", arg)
148 :     }
149 :    
150 :     get_user_name(id, name, 31)
151 :    
152 :     switch (get_cvar_num("amx_show_activity"))
153 :     {
154 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_UNBAN_2", name, arg)
155 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_UNBAN_1", arg)
156 :     }
157 :    
158 :     get_user_authid(id, authid, 31)
159 :     log_amx("Cmd: ^"%s<%d><%s><>^" unban ^"%s^"", name, get_user_userid(id), authid, arg)
160 :    
161 :     return PLUGIN_HANDLED
162 :     }
163 :    
164 :     public cmdAddBan(id, level, cid)
165 :     {
166 :     if (!cmd_access(id, level, cid, 3))
167 :     return PLUGIN_HANDLED
168 :    
169 :     new arg[32], authid[32], name[32], minutes[32], reason[32]
170 :    
171 :     read_argv(1, arg, 31)
172 :     read_argv(2, minutes, 31)
173 :     read_argv(3, reason, 31)
174 :    
175 :     if (contain(arg, ".") != -1)
176 :     {
177 :     server_cmd("addip ^"%s^" ^"%s^";wait;writeip", minutes, arg)
178 :     console_print(id, "[AMXX] Ip ^"%s^" added to ban list", arg)
179 :     } else {
180 :     server_cmd("banid ^"%s^" ^"%s^";wait;writeid", minutes, arg)
181 :     console_print(id, "[AMXX] Authid ^"%s^" added to ban list", arg)
182 :     }
183 :    
184 :     get_user_name(id, name, 31)
185 :    
186 :     switch (get_cvar_num("amx_show_activity"))
187 :     {
188 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_ADDBAN_2", name, arg)
189 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_ADDBAN_1", arg)
190 :     }
191 :    
192 :     get_user_authid(id, authid, 31)
193 :     log_amx("Cmd: ^"%s<%d><%s><>^" ban ^"%s^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, arg, minutes, reason)
194 :    
195 :     return PLUGIN_HANDLED
196 :     }
197 :    
198 :     public cmdBan(id, level, cid)
199 :     {
200 :     if (!cmd_access(id, level, cid, 3))
201 :     return PLUGIN_HANDLED
202 :    
203 :     new target[32], minutes[8], reason[64]
204 :    
205 :     read_argv(1, target, 31)
206 :     read_argv(2, minutes, 7)
207 :     read_argv(3, reason, 63)
208 :    
209 :     new player = cmd_target(id, target, 9)
210 :    
211 :     if (!player)
212 :     return PLUGIN_HANDLED
213 :    
214 :     new authid[32], name2[32], authid2[32], name[32]
215 :     new userid2 = get_user_userid(player)
216 :    
217 :     get_user_authid(player, authid2, 31)
218 :     get_user_authid(id, authid, 31)
219 :     get_user_name(player, name2, 31)
220 :     get_user_name(id, name, 31)
221 :    
222 :     log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason)
223 :    
224 :     new temp[64], banned[16], nNum = str_to_num(minutes)
225 :     if (nNum)
226 :     format(temp, 63, "%L", player, "FOR_MIN", minutes)
227 :     else
228 :     format(temp, 63, "%L", player, "PERM")
229 :    
230 :     format(banned, 15, "%L", player, "BANNED")
231 :    
232 :     if (reason[0])
233 :     server_cmd("kick #%d ^"%s (%s %s)^";wait;banid ^"%s^" ^"%s^";wait;writeid", userid2, reason, banned, temp, minutes, authid2)
234 :     else
235 :     server_cmd("kick #%d ^"%s %s^";wait;banid ^"%s^" ^"%s^";wait;writeid", userid2, banned, temp, minutes, authid2)
236 :    
237 :     new activity = get_cvar_num("amx_show_activity")
238 :     if (activity != 0)
239 :     {
240 :     new players[32], pnum, msg[256], len
241 :     get_players(players, pnum, "c")
242 :    
243 :     for (new i = 0; i < pnum; i++)
244 :     {
245 :     len = format(msg, 255, "%L", players[i], "ADMIN")
246 :    
247 :     if (activity == 1)
248 :     len += copy(msg[len], 255-len, ":")
249 :     else
250 :     len += format(msg[len], 255-len, " %s:", name)
251 :    
252 :     len += format(msg[len], 255-len, " %L", players[i], "BAN")
253 :     len += format(msg[len], 255-len, " %s ", name2)
254 :    
255 :     if (nNum)
256 :     format(msg[len], 255-len, "%L", players[i], "FOR_MIN", minutes)
257 :     else
258 :     format(msg[len], 255-len, "%L", players[i], "PERM")
259 :    
260 :     client_print(players[i], print_chat, "%s", msg)
261 :     }
262 :     }
263 :     console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)
264 :    
265 :     return PLUGIN_HANDLED
266 :     }
267 :    
268 :     public cmdBanIP(id, level, cid)
269 :     {
270 :     if (!cmd_access(id, level, cid, 3))
271 :     return PLUGIN_HANDLED
272 :    
273 :     new target[32], minutes[8], reason[64]
274 :    
275 :     read_argv(1, target, 31)
276 :     read_argv(2, minutes, 7)
277 :     read_argv(3, reason, 63)
278 :    
279 :     new player = cmd_target(id, target, 9)
280 :    
281 :     if (!player)
282 :     return PLUGIN_HANDLED
283 :    
284 :     new authid[32], name2[32], authid2[32], name[32]
285 :     new userid2 = get_user_userid(player)
286 :    
287 :     get_user_authid(player, authid2, 31)
288 :     get_user_authid(id, authid, 31)
289 :     get_user_name(player, name2, 31)
290 :     get_user_name(id, name, 31)
291 :    
292 :     log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason)
293 :    
294 :     new temp[64], banned[16], nNum = str_to_num(minutes)
295 :     if (nNum)
296 :     format(temp, 63, "%L", player, "FOR_MIN", minutes)
297 :     else
298 :     format(temp, 63, "%L", player, "PERM")
299 :     format(banned, 15, "%L", player, "BANNED")
300 :    
301 :     new address[32]
302 :     get_user_ip(player, address, 31, 1)
303 :    
304 :     if (reason[0])
305 :     server_cmd("kick #%d ^"%s (%s %s)^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, reason, banned, temp, minutes, address)
306 :     else
307 :     server_cmd("kick #%d ^"%s %s^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, banned, temp, minutes, address)
308 :    
309 :     new activity = get_cvar_num("amx_show_activity")
310 :     if (activity != 0)
311 :     {
312 :     new players[32], pnum, msg[256], len
313 :     get_players(players, pnum, "c")
314 :    
315 :     for (new i = 0; i < pnum; i++)
316 :     {
317 :     len = format(msg, 255, "%L", players[i], "ADMIN")
318 :    
319 :     if (activity == 1)
320 :     len += copy(msg[len], 255-len, ":")
321 :     else
322 :     len += format(msg[len], 255-len, " %s:", name)
323 :    
324 :     len += format(msg[len], 255-len, " %L", players[i], "BAN")
325 :     len += format(msg[len], 255-len, " %s ", name2)
326 :    
327 :     if (nNum)
328 :     format(msg[len], 255-len, "%L", players[i], "FOR_MIN", minutes)
329 :     else
330 :     format(msg[len], 255-len, "%L", players[i], "PERM")
331 :    
332 :     client_print(players[i], print_chat, "%s", msg)
333 :     }
334 :     }
335 :     console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)
336 :    
337 :     return PLUGIN_HANDLED
338 :     }
339 :    
340 :     public cmdSlay(id, level, cid)
341 :     {
342 :     if (!cmd_access(id, level, cid, 2))
343 :     return PLUGIN_HANDLED
344 :    
345 :     new arg[32]
346 :    
347 :     read_argv(1, arg, 31)
348 :    
349 :     new player = cmd_target(id, arg, 5)
350 :    
351 :     if (!player)
352 :     return PLUGIN_HANDLED
353 :    
354 :     user_kill(player)
355 :    
356 :     new authid[32], name2[32], authid2[32], name[32]
357 :    
358 :     get_user_authid(id, authid, 31)
359 :     get_user_name(id, name, 31)
360 :     get_user_authid(player, authid2, 31)
361 :     get_user_name(player, name2, 31)
362 :    
363 :     log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
364 :    
365 :     switch (get_cvar_num("amx_show_activity"))
366 :     {
367 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAY_2", name, name2)
368 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAY_1", name2)
369 :     }
370 :     console_print(id, "[AMXX] %L", id, "CLIENT_SLAYED", name2)
371 :    
372 :     return PLUGIN_HANDLED
373 :     }
374 :    
375 :     public cmdSlap(id, level, cid)
376 :     {
377 :     if (!cmd_access(id, level, cid, 2))
378 :     return PLUGIN_HANDLED
379 :    
380 :     new arg[32]
381 :    
382 :     read_argv(1, arg, 31)
383 :     new player = cmd_target(id, arg, 5)
384 :    
385 :     if (!player)
386 :     return PLUGIN_HANDLED
387 :    
388 :     new spower[32], authid[32], name2[32], authid2[32], name[32]
389 :    
390 :     read_argv(2, spower, 31)
391 :    
392 :     new damage = str_to_num(spower)
393 :    
394 :     user_slap(player, damage)
395 :    
396 :     get_user_authid(id, authid, 31)
397 :     get_user_name(id, name, 31)
398 :     get_user_authid(player, authid2, 31)
399 :     get_user_name(player, name2, 31)
400 :    
401 :     log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, damage, name2, get_user_userid(player), authid2)
402 :    
403 :     switch (get_cvar_num("amx_show_activity"))
404 :     {
405 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAP_2", name, name2, damage)
406 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_SLAP_1", name2, damage)
407 :     }
408 :     console_print(id, "[AMXX] %L", id, "CLIENT_SLAPED", name2, damage)
409 :    
410 :     return PLUGIN_HANDLED
411 :     }
412 :    
413 :     public chMap(map[])
414 :     {
415 :     server_cmd("changelevel %s", map)
416 :     }
417 :    
418 :     public cmdMap(id, level, cid)
419 :     {
420 :     if (!cmd_access(id, level, cid, 2))
421 :     return PLUGIN_HANDLED
422 :    
423 :     new arg[32]
424 :     new arglen = read_argv(1, arg, 31)
425 :    
426 :     if (!is_map_valid(arg))
427 :     {
428 :     console_print(id, "[AMXX] %L", id, "MAP_NOT_FOUND")
429 :     return PLUGIN_HANDLED
430 :     }
431 :    
432 :     new authid[32], name[32]
433 :    
434 :     get_user_authid(id, authid, 31)
435 :     get_user_name(id, name, 31)
436 :    
437 :     switch (get_cvar_num("amx_show_activity"))
438 :     {
439 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_MAP_2", name, arg)
440 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_MAP_1", arg)
441 :     }
442 :    
443 :     log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", name, get_user_userid(id), authid, arg)
444 :    
445 :     new _modName[10]
446 :     get_modname(_modName, 9)
447 :    
448 :     if (!equal(_modName, "zp"))
449 :     {
450 :     message_begin(MSG_ALL, SVC_INTERMISSION)
451 :     message_end()
452 :     }
453 :    
454 :     set_task(2.0, "chMap", 0, arg, arglen + 1)
455 :    
456 :     return PLUGIN_HANDLED
457 :     }
458 :    
459 :     onlyRcon(name[])
460 :     {
461 :     for (new a = 0; a < g_cvarRconNum; ++a)
462 :     if (equali(g_cvarRcon[a], name))
463 :     return 1
464 :     return 0
465 :     }
466 :    
467 :     public cmdCvar(id, level, cid)
468 :     {
469 :     if (!cmd_access(id, level, cid, 2))
470 :     return PLUGIN_HANDLED
471 :    
472 :     new arg[32], arg2[64]
473 :    
474 :     read_argv(1, arg, 31)
475 :     read_argv(2, arg2, 63)
476 :    
477 :     if (equal(arg, "add") && (get_user_flags(id) & ADMIN_RCON))
478 :     {
479 :     if (cvar_exists(arg2))
480 :     {
481 :     if (g_cvarRconNum < MAXRCONCVARS)
482 :     copy(g_cvarRcon[g_cvarRconNum++], 31, arg2)
483 :     else
484 :     console_print(id, "[AMXX] %L", id, "NO_MORE_CVARS")
485 :     }
486 :     return PLUGIN_HANDLED
487 :     }
488 :    
489 :     if (!cvar_exists(arg))
490 :     {
491 :     console_print(id, "[AMXX] %L", id, "UNKNOWN_CVAR", arg)
492 :     return PLUGIN_HANDLED
493 :     }
494 :    
495 :     if (onlyRcon(arg) && !(get_user_flags(id) & ADMIN_RCON))
496 :     {
497 :     console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC")
498 :     return PLUGIN_HANDLED
499 :     }
500 :     else if (equal(arg, "sv_password") && !(get_user_flags(id) & ADMIN_PASSWORD))
501 :     {
502 :     console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC")
503 :     return PLUGIN_HANDLED
504 :     }
505 :    
506 :     if (read_argc() < 3)
507 :     {
508 :     get_cvar_string(arg, arg2, 63)
509 :     console_print(id, "[AMXX] %L", id, "CVAR_IS", arg, arg2)
510 :     return PLUGIN_HANDLED
511 :     }
512 :    
513 :     new authid[32], name[32]
514 :    
515 :     get_user_authid(id, authid, 31)
516 :     get_user_name(id, name, 31)
517 :    
518 :     log_amx("Cmd: ^"%s<%d><%s><>^" set cvar (name ^"%s^") (value ^"%s^")", name, get_user_userid(id), authid, arg, arg2)
519 :     set_cvar_string(arg, arg2)
520 :    
521 :     new activity = get_cvar_num("amx_show_activity")
522 :     if (activity != 0)
523 :     {
524 :     new players[32], pnum, admin[64], cvar_val[64], len
525 :     get_players(players, pnum, "c")
526 :    
527 :     for (new i = 0; i < pnum; i++)
528 :     {
529 :     len = format(admin, 255, "%L", players[i], "ADMIN")
530 :    
531 :     if (activity == 1)
532 :     len += copy(admin[len], 255-len, ":")
533 :     else
534 :     len += format(admin[len], 255-len, " %s:", name)
535 :    
536 :     if (equal(arg, "rcon_password") || equal(arg, "sv_password"))
537 :     format(cvar_val, 63, "*** %L ***", players[i], "PROTECTED")
538 :     else
539 :     copy(cvar_val, 63, arg2)
540 :    
541 :     client_print(players[i], print_chat, "%L", players[i], "SET_CVAR_TO", admin, arg, arg2)
542 :     }
543 :     }
544 :     console_print(id, "[AMXX] %L", id, "CVAR_CHANGED", arg, arg2)
545 :    
546 :     return PLUGIN_HANDLED
547 :     }
548 :    
549 :     public cmdPlugins(id, level, cid)
550 :     {
551 :     if (!cmd_access(id, level, cid, 1))
552 :     return PLUGIN_HANDLED
553 :    
554 :     new name[32], version[32], author[32], filename[32], status[32]
555 :     new lName[32], lVersion[32], lAuthor[32], lFile[32], lStatus[32]
556 :    
557 :     format(lName, 31, "%L", id, "NAME")
558 :     format(lVersion, 31, "%L", id, "VERSION")
559 :     format(lAuthor, 31, "%L", id, "AUTHOR")
560 :     format(lFile, 31, "%L", id, "FILE")
561 :     format(lStatus, 31, "%L", id, "STATUS")
562 :    
563 :     new num = get_pluginsnum()
564 :     new running = 0
565 :    
566 :     console_print(id, "%L:", id, "LOADED_PLUGINS")
567 :     console_print(id, "%-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", lName, lVersion, lAuthor, lFile, lStatus)
568 :    
569 :     for (new i = 0; i <num; i++)
570 :     {
571 :     get_plugin(i, filename, 31, name, 31, version, 31, author, 31, status, 31)
572 :     console_print(id, "%-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", name, version, author, filename, status)
573 :    
574 :     if (status[0]=='d' || status[0]=='r') // "debug" or "running"
575 :     running++
576 :     }
577 :     console_print(id, "%L", id, "PLUGINS_RUN", num, running)
578 :    
579 :     return PLUGIN_HANDLED
580 :     }
581 :    
582 :     public cmdModules(id, level, cid)
583 :     {
584 :     if (!cmd_access(id, level, cid, 1))
585 :     return PLUGIN_HANDLED
586 :    
587 :     new name[32], version[32], author[32], status, sStatus[16]
588 :     new lName[32], lVersion[32], lAuthor[32]
589 :    
590 :     format(lName, 31, "%L", id, "NAME")
591 :     format(lVersion, 31, "%L", id, "VERSION")
592 :     format(lAuthor, 31, "%L", id, "AUTHOR")
593 :    
594 :     new num = get_modulesnum()
595 :    
596 :     console_print(id, "%L:", id, "LOADED_MODULES")
597 :     console_print(id, "%-23.22s %-8.7s %-20.19s", lName, lVersion, lAuthor)
598 :    
599 :     for (new i = 0; i < num; i++)
600 :     {
601 :     get_module(i, name, 31, author, 31, version, 31, status)
602 :    
603 :     switch (status)
604 :     {
605 :     case module_loaded: copy(sStatus, 15, "running")
606 :     default: copy(sStatus, 15, "error")
607 :     }
608 :    
609 :     console_print(id, "%-23.22s %-8.7s %-20.19s", name, version, author)
610 :     }
611 :     console_print(id, "%L", id, "NUM_MODULES", num)
612 :    
613 :     return PLUGIN_HANDLED
614 :     }
615 :    
616 :     public cmdCfg(id, level, cid)
617 :     {
618 :     if (!cmd_access(id, level, cid, 2))
619 :     return PLUGIN_HANDLED
620 :    
621 :     new arg[128]
622 :     read_argv(1, arg, 127)
623 :    
624 :     if (!file_exists(arg))
625 :     {
626 :     console_print(id, "[AMXX] %L", id, "FILE_NOT_FOUND", arg)
627 :     return PLUGIN_HANDLED
628 :     }
629 :    
630 :     new authid[32], name[32]
631 :    
632 :     get_user_authid(id, authid, 31)
633 :     get_user_name(id, name, 31)
634 :    
635 :     log_amx("Cmd: ^"%s<%d><%s><>^" execute cfg (file ^"%s^")", name, get_user_userid(id), authid, arg)
636 :    
637 :     console_print(id, "[AMXX] Executing file ^"%s^"", arg)
638 :     server_cmd("exec %s", arg)
639 :    
640 :     switch(get_cvar_num("amx_show_activity"))
641 :     {
642 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_CONF_2", name, arg)
643 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_CONF_1", arg)
644 :     }
645 :    
646 :     return PLUGIN_HANDLED
647 :     }
648 :    
649 :     public cmdLBack()
650 :     {
651 :     if (!g_PauseAllowed)
652 :     return PLUGIN_CONTINUE
653 :    
654 :     new paused[25]
655 :    
656 :     format(paused, 24, "%L", g_pauseCon, g_Paused ? "UNPAUSED" : "PAUSED")
657 :     set_cvar_float("pausable", g_pausAble)
658 :     console_print(g_pauseCon, "[AMXX] Server %s", paused)
659 :     g_PauseAllowed = false
660 :    
661 :     if (g_Paused)
662 :     g_Paused = false
663 :     else
664 :     g_Paused = true
665 :    
666 :     return PLUGIN_HANDLED
667 :     }
668 :    
669 :     public cmdPause(id, level, cid)
670 :     {
671 :     if (!cmd_access(id, level, cid, 1))
672 :     return PLUGIN_HANDLED
673 :    
674 :     new authid[32], name[32], slayer = id
675 :    
676 :     get_user_authid(id, authid, 31)
677 :     get_user_name(id, name, 31)
678 :     g_pausAble = get_cvar_float("pausable")
679 :    
680 :     if (!slayer)
681 :     slayer = find_player("h")
682 :    
683 :     if (!slayer)
684 :     {
685 :     console_print(id, "[AMXX] %L", id, "UNABLE_PAUSE")
686 :     return PLUGIN_HANDLED
687 :     }
688 :    
689 :     set_cvar_float("pausable", 1.0)
690 :     g_PauseAllowed = true
691 :     client_cmd(slayer, "pause;pauseAck")
692 :    
693 :     log_amx("Cmd: ^"%s<%d><%s><>^" %s server", name, get_user_userid(id), authid, g_Paused ? "unpause" : "pause")
694 :    
695 :     console_print(id, "[AMXX] %L", id, g_Paused ? "UNPAUSING" : "PAUSING")
696 :    
697 :     new activity = get_cvar_num("amx_show_activity")
698 :     if (activity != 0)
699 :     {
700 :     new players[32], pnum, msg[128], len
701 :     get_players(players, pnum, "c")
702 :    
703 :     for (new i = 0; i < pnum; i++)
704 :     {
705 :     len = format(msg, 127, "%L", players[i], "ADMIN")
706 :    
707 :     if (activity == 1)
708 :     len += copy(msg[len], 127-len, ": ")
709 :     else
710 :     len += format(msg[len], 127-len, " %s: ", name)
711 :    
712 :     format(msg[len], 127-len, "%L", players[i], g_Paused ? "UNPAUSE" : "PAUSE")
713 :     client_print(players[i], print_chat, "%s server", msg)
714 :     }
715 :     }
716 :     g_pauseCon = id
717 :    
718 :     return PLUGIN_HANDLED
719 :     }
720 :    
721 :     public cmdShowRcon(id, level, cid)
722 :     {
723 :     if (!cmd_access(id, level, cid, 2))
724 :     return PLUGIN_HANDLED
725 :    
726 :     new password[64]
727 :    
728 :     get_cvar_string("rcon_password", password, 63)
729 :    
730 :     if (!password[0])
731 :     {
732 :     cmdRcon(id, level, cid)
733 :     } else {
734 :     new args[128]
735 :    
736 :     read_args(args, 127)
737 :     client_cmd(id, "rcon_password %s", password)
738 :     client_cmd(id, "rcon %s", args)
739 :     }
740 :    
741 :     return PLUGIN_HANDLED
742 :     }
743 :    
744 :     public cmdRcon(id, level, cid)
745 :     {
746 :     if (!cmd_access(id, level, cid, 2))
747 :     return PLUGIN_HANDLED
748 :    
749 :     new arg[128], authid[32], name[32]
750 :    
751 :     read_args(arg, 127)
752 :     get_user_authid(id, authid, 31)
753 :     get_user_name(id, name, 31)
754 :    
755 :     log_amx("Cmd: ^"%s<%d><%s><>^" server console (cmdline ^"%s^")", name, get_user_userid(id), authid, arg)
756 :    
757 :     console_print(id, "[AMXX] %L", id, "COM_SENT_SERVER", arg)
758 :     server_cmd("%s", arg)
759 :    
760 :     return PLUGIN_HANDLED
761 :     }
762 :    
763 :     public cmdWho(id, level, cid)
764 :     {
765 :     if (!cmd_access(id, level, cid, 1))
766 :     return PLUGIN_HANDLED
767 :    
768 :     new players[32], inum, cl_on_server[64], authid[32], name[32], flags, sflags[32]
769 :     new lImm[16], lRes[16], lAccess[16], lYes[16], lNo[16]
770 :    
771 :     format(lImm, 15, "%L", id, "IMMU")
772 :     format(lRes, 15, "%L", id, "RESERV")
773 :     format(lAccess, 15, "%L", id, "ACCESS")
774 :     format(lYes, 15, "%L", id, "YES")
775 :     format(lNo, 15, "%L", id, "NO")
776 :    
777 :     get_players(players, inum)
778 :     format(cl_on_server, 63, "%L", id, "CLIENTS_ON_SERVER")
779 :     console_print(id, "^n%s:^n # %-16.15s %-20s %-8s %-4.3s %-4.3s %s", cl_on_server, "nick", "authid", "userid", lImm, lRes, lAccess)
780 :    
781 :     for (new a = 0; a < inum; ++a)
782 :     {
783 :     get_user_authid(players[a], authid, 31)
784 :     get_user_name(players[a], name, 31)
785 :     flags = get_user_flags(players[a])
786 :     get_flags(flags, sflags, 31)
787 :     console_print(id, "%2d %-16.15s %-20s %-8d %-6.5s %-6.5s %s", players[a], name, authid,
788 :     get_user_userid(players[a]), (flags&ADMIN_IMMUNITY) ? lYes : lNo, (flags&ADMIN_RESERVATION) ? lYes : lNo, sflags)
789 :     }
790 :    
791 :     console_print(id, "%L", id, "TOTAL_NUM", inum)
792 :     get_user_authid(id, authid, 31)
793 :     get_user_name(id, name, 31)
794 :     log_amx("Cmd: ^"%s<%d><%s><>^" ask for players list", name, get_user_userid(id), authid)
795 :    
796 :     return PLUGIN_HANDLED
797 :     }
798 :    
799 :     hasTag(name[], tags[4][32], tagsNum)
800 :     {
801 :     for (new a = 0; a < tagsNum; ++a)
802 :     if (contain(name, tags[a]) != -1)
803 :     return a
804 :     return -1
805 :     }
806 :    
807 :     public cmdLeave(id, level, cid)
808 :     {
809 :     if (!cmd_access(id, level, cid, 2))
810 :     return PLUGIN_HANDLED
811 :    
812 :     new argnum = read_argc()
813 :     new ltags[4][32]
814 :     new ltagsnum = 0
815 :    
816 :     for (new a = 1; a < 5; ++a)
817 :     {
818 :     if (a < argnum)
819 :     read_argv(a, ltags[ltagsnum++], 31)
820 :     else
821 :     ltags[ltagsnum++][0] = 0
822 :     }
823 :    
824 :     new nick[32], ires, pnum = get_maxplayers() + 1, count = 0, lReason[128]
825 :    
826 :     for (new b = 1; b < pnum; ++b)
827 :     {
828 :     if (!is_user_connected(b) && !is_user_connecting(b)) continue
829 :    
830 :     get_user_name(b, nick, 31)
831 :     ires = hasTag(nick, ltags, ltagsnum)
832 :    
833 :     if (ires != -1)
834 :     {
835 :     console_print(id, "[AMXX] %L", id, "SKIP_MATCH", nick, ltags[ires])
836 :     continue
837 :     }
838 :    
839 :     if (get_user_flags(b) & ADMIN_IMMUNITY)
840 :     {
841 :     console_print(id, "[AMXX] %L", id, "SKIP_IMM", nick)
842 :     continue
843 :     }
844 :    
845 :     console_print(id, "[AMXX] %L", id, "KICK_PL", nick)
846 :    
847 :     if (is_user_bot(b))
848 :     server_cmd("kick #%d", get_user_userid(b))
849 :     else
850 :     {
851 :     format(lReason, 127, "%L", b, "YOU_DROPPED")
852 :     server_cmd("kick #%d ^"%s^"", get_user_userid(b), lReason)
853 :     }
854 :     count++
855 :     }
856 :    
857 :     console_print(id, "[AMXX] %L", id, "KICKED_CLIENTS", count)
858 :    
859 :     new authid[32], name[32]
860 :    
861 :     get_user_authid(id, authid, 31)
862 :     get_user_name(id, name, 31)
863 :     log_amx("Kick: ^"%s<%d><%s><>^" leave some group (tag1 ^"%s^") (tag2 ^"%s^") (tag3 ^"%s^") (tag4 ^"%s^")", name, get_user_userid(id), authid, ltags[0], ltags[1], ltags[2], ltags[3])
864 :    
865 :     switch(get_cvar_num("amx_show_activity"))
866 :     {
867 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_LEAVE_2", name, ltags[0], ltags[1], ltags[2], ltags[3])
868 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_LEAVE_1", ltags[0], ltags[1], ltags[2], ltags[3])
869 :     }
870 :    
871 :     return PLUGIN_HANDLED
872 :     }
873 :    
874 :     public cmdNick(id, level, cid)
875 :     {
876 :     if (!cmd_access(id, level, cid, 3))
877 :     return PLUGIN_HANDLED
878 :    
879 :     new arg1[32], arg2[32], authid[32], name[32], authid2[32], name2[32]
880 :    
881 :     read_argv(1, arg1, 31)
882 :     read_argv(2, arg2, 31)
883 :    
884 :     new player = cmd_target(id, arg1, 1)
885 :    
886 :     if (!player)
887 :     return PLUGIN_HANDLED
888 :    
889 :     get_user_authid(id, authid, 31)
890 :     get_user_name(id, name, 31)
891 :     get_user_authid(player, authid2, 31)
892 :     get_user_name(player, name2, 31)
893 :    
894 :     client_cmd(player, "name ^"%s^"", arg2)
895 :    
896 :     log_amx("Cmd: ^"%s<%d><%s><>^" change nick to ^"%s^" ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, arg2, name2, get_user_userid(player), authid2)
897 :    
898 :     switch (get_cvar_num("amx_show_activity"))
899 :     {
900 :     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_NICK_2", name, name2, arg2)
901 :     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_NICK_1", name2, arg2)
902 :     }
903 :     console_print(id, "[AMXX] %L", id, "CHANGED_NICK", name2, arg2)
904 :    
905 :     return PLUGIN_HANDLED
906 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4