Parent Directory | Revision Log
Revision 44 - (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 : | ian | 17 | // This is not a dynamic array because it would be bad for 24/7 map servers. |
39 : | #define OLD_CONNECTION_QUEUE 10 | ||
40 : | ian | 1 | |
41 : | new g_pauseCon | ||
42 : | new Float:g_pausAble | ||
43 : | new bool:g_Paused | ||
44 : | new bool:g_PauseAllowed = false | ||
45 : | new g_addCvar[] = "amx_cvar add %s" | ||
46 : | |||
47 : | ian | 17 | new pausable; |
48 : | new rcon_password; | ||
49 : | |||
50 : | // Old connection queue | ||
51 : | new g_Names[OLD_CONNECTION_QUEUE][32]; | ||
52 : | new g_SteamIDs[OLD_CONNECTION_QUEUE][32]; | ||
53 : | new g_IPs[OLD_CONNECTION_QUEUE][32]; | ||
54 : | new g_Access[OLD_CONNECTION_QUEUE]; | ||
55 : | new g_Tracker; | ||
56 : | new g_Size; | ||
57 : | |||
58 : | stock InsertInfo(id) | ||
59 : | { | ||
60 : | |||
61 : | // Scan to see if this entry is the last entry in the list | ||
62 : | // If it is, then update the name and access | ||
63 : | // If it is not, then insert it again. | ||
64 : | |||
65 : | if (g_Size > 0) | ||
66 : | { | ||
67 : | new ip[32] | ||
68 : | new auth[32]; | ||
69 : | |||
70 : | get_user_authid(id, auth, charsmax(auth)); | ||
71 : | get_user_ip(id, ip, charsmax(ip), 1/*no port*/); | ||
72 : | |||
73 : | new last = 0; | ||
74 : | |||
75 : | if (g_Size < sizeof(g_SteamIDs)) | ||
76 : | { | ||
77 : | last = g_Size - 1; | ||
78 : | } | ||
79 : | else | ||
80 : | { | ||
81 : | last = g_Tracker - 1; | ||
82 : | |||
83 : | if (last < 0) | ||
84 : | { | ||
85 : | last = g_Size - 1; | ||
86 : | } | ||
87 : | } | ||
88 : | |||
89 : | if (equal(auth, g_SteamIDs[last]) && | ||
90 : | equal(ip, g_IPs[last])) // need to check ip too, or all the nosteams will while it doesn't work with their illegitimate server | ||
91 : | { | ||
92 : | get_user_name(id, g_Names[last], charsmax(g_Names[])); | ||
93 : | g_Access[last] = get_user_flags(id); | ||
94 : | |||
95 : | return; | ||
96 : | } | ||
97 : | } | ||
98 : | |||
99 : | // Need to insert the entry | ||
100 : | |||
101 : | new target = 0; // the slot to save the info at | ||
102 : | |||
103 : | // Queue is not yet full | ||
104 : | if (g_Size < sizeof(g_SteamIDs)) | ||
105 : | { | ||
106 : | target = g_Size; | ||
107 : | |||
108 : | ++g_Size; | ||
109 : | |||
110 : | } | ||
111 : | else | ||
112 : | { | ||
113 : | target = g_Tracker; | ||
114 : | |||
115 : | ++g_Tracker; | ||
116 : | // If we reached the end of the array, then move to the front | ||
117 : | if (g_Tracker == sizeof(g_SteamIDs)) | ||
118 : | { | ||
119 : | g_Tracker = 0; | ||
120 : | } | ||
121 : | } | ||
122 : | |||
123 : | get_user_authid(id, g_SteamIDs[target], charsmax(g_SteamIDs[])); | ||
124 : | get_user_name(id, g_Names[target], charsmax(g_Names[])); | ||
125 : | get_user_ip(id, g_IPs[target], charsmax(g_IPs[]), 1/*no port*/); | ||
126 : | |||
127 : | g_Access[target] = get_user_flags(id); | ||
128 : | |||
129 : | } | ||
130 : | stock GetInfo(i, name[], namesize, auth[], authsize, ip[], ipsize, &access) | ||
131 : | { | ||
132 : | if (i >= g_Size) | ||
133 : | { | ||
134 : | abort(AMX_ERR_NATIVE, "GetInfo: Out of bounds (%d:%d)", i, g_Size); | ||
135 : | } | ||
136 : | |||
137 : | new target = (g_Tracker + i) % sizeof(g_SteamIDs); | ||
138 : | |||
139 : | copy(name, namesize, g_Names[target]); | ||
140 : | copy(auth, authsize, g_SteamIDs[target]); | ||
141 : | copy(ip, ipsize, g_IPs[target]); | ||
142 : | access = g_Access[target]; | ||
143 : | |||
144 : | } | ||
145 : | public client_disconnect(id) | ||
146 : | { | ||
147 : | if (!is_user_bot(id)) | ||
148 : | { | ||
149 : | InsertInfo(id); | ||
150 : | } | ||
151 : | } | ||
152 : | |||
153 : | ian | 1 | public plugin_init() |
154 : | { | ||
155 : | register_plugin("Admin Commands", AMXX_VERSION_STR, "AMXX Dev Team") | ||
156 : | ian | 17 | |
157 : | ian | 1 | register_dictionary("admincmd.txt") |
158 : | register_dictionary("common.txt") | ||
159 : | ian | 17 | register_dictionary("adminhelp.txt") |
160 : | |||
161 : | |||
162 : | ian | 1 | register_concmd("amx_kick", "cmdKick", ADMIN_KICK, "<name or #userid> [reason]") |
163 : | register_concmd("amx_ban", "cmdBan", ADMIN_BAN, "<name or #userid> <minutes> [reason]") | ||
164 : | register_concmd("amx_banip", "cmdBanIP", ADMIN_BAN, "<name or #userid> <minutes> [reason]") | ||
165 : | ian | 17 | register_concmd("amx_addban", "cmdAddBan", ADMIN_BAN, "<^"authid^" or ip> <minutes> [reason]") |
166 : | register_concmd("amx_unban", "cmdUnban", ADMIN_BAN, "<^"authid^" or ip>") | ||
167 : | ian | 1 | register_concmd("amx_slay", "cmdSlay", ADMIN_SLAY, "<name or #userid>") |
168 : | register_concmd("amx_slap", "cmdSlap", ADMIN_SLAY, "<name or #userid> [power]") | ||
169 : | register_concmd("amx_leave", "cmdLeave", ADMIN_KICK, "<tag> [tag] [tag] [tag]") | ||
170 : | register_concmd("amx_pause", "cmdPause", ADMIN_CVAR, "- pause or unpause the game") | ||
171 : | register_concmd("amx_who", "cmdWho", ADMIN_ADMIN, "- displays who is on server") | ||
172 : | register_concmd("amx_cvar", "cmdCvar", ADMIN_CVAR, "<cvar> [value]") | ||
173 : | register_concmd("amx_plugins", "cmdPlugins", ADMIN_ADMIN) | ||
174 : | register_concmd("amx_modules", "cmdModules", ADMIN_ADMIN) | ||
175 : | register_concmd("amx_map", "cmdMap", ADMIN_MAP, "<mapname>") | ||
176 : | register_concmd("amx_cfg", "cmdCfg", ADMIN_CFG, "<filename>") | ||
177 : | register_concmd("amx_nick", "cmdNick", ADMIN_SLAY, "<name or #userid> <new nick>") | ||
178 : | ian | 17 | register_concmd("amx_last", "cmdLast", ADMIN_BAN, "- list the last few disconnected clients info"); |
179 : | ian | 1 | register_clcmd("amx_rcon", "cmdRcon", ADMIN_RCON, "<command line>") |
180 : | register_clcmd("amx_showrcon", "cmdShowRcon", ADMIN_RCON, "<command line>") | ||
181 : | register_clcmd("pauseAck", "cmdLBack") | ||
182 : | ian | 17 | |
183 : | |||
184 : | rcon_password=get_cvar_pointer("rcon_password"); | ||
185 : | pausable=get_cvar_pointer("pausable"); | ||
186 : | |||
187 : | |||
188 : | ian | 1 | } |
189 : | |||
190 : | public plugin_cfg() | ||
191 : | { | ||
192 : | // Cvars which can be changed only with rcon access | ||
193 : | server_cmd(g_addCvar, "rcon_password") | ||
194 : | server_cmd(g_addCvar, "amx_show_activity") | ||
195 : | server_cmd(g_addCvar, "amx_mode") | ||
196 : | server_cmd(g_addCvar, "amx_password_field") | ||
197 : | server_cmd(g_addCvar, "amx_default_access") | ||
198 : | server_cmd(g_addCvar, "amx_reserved_slots") | ||
199 : | server_cmd(g_addCvar, "amx_reservation") | ||
200 : | ian | 17 | server_cmd(g_addCvar, "amx_sql_table"); |
201 : | server_cmd(g_addCvar, "amx_sql_host"); | ||
202 : | server_cmd(g_addCvar, "amx_sql_user"); | ||
203 : | server_cmd(g_addCvar, "amx_sql_pass"); | ||
204 : | server_cmd(g_addCvar, "amx_sql_db"); | ||
205 : | server_cmd(g_addCvar, "amx_sql_type"); | ||
206 : | |||
207 : | ian | 1 | } |
208 : | |||
209 : | public cmdKick(id, level, cid) | ||
210 : | { | ||
211 : | if (!cmd_access(id, level, cid, 2)) | ||
212 : | return PLUGIN_HANDLED | ||
213 : | |||
214 : | new arg[32] | ||
215 : | read_argv(1, arg, 31) | ||
216 : | ian | 17 | new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF) |
217 : | ian | 1 | |
218 : | if (!player) | ||
219 : | return PLUGIN_HANDLED | ||
220 : | |||
221 : | new authid[32], authid2[32], name2[32], name[32], userid2, reason[32] | ||
222 : | |||
223 : | get_user_authid(id, authid, 31) | ||
224 : | get_user_authid(player, authid2, 31) | ||
225 : | get_user_name(player, name2, 31) | ||
226 : | get_user_name(id, name, 31) | ||
227 : | userid2 = get_user_userid(player) | ||
228 : | read_argv(2, reason, 31) | ||
229 : | remove_quotes(reason) | ||
230 : | |||
231 : | log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^" (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, reason) | ||
232 : | |||
233 : | ian | 17 | show_activity_key("ADMIN_KICK_1", "ADMIN_KICK_2", name, name2); |
234 : | |||
235 : | ian | 1 | if (is_user_bot(player)) |
236 : | server_cmd("kick #%d", userid2) | ||
237 : | else | ||
238 : | { | ||
239 : | if (reason[0]) | ||
240 : | server_cmd("kick #%d ^"%s^"", userid2, reason) | ||
241 : | else | ||
242 : | server_cmd("kick #%d", userid2) | ||
243 : | } | ||
244 : | |||
245 : | console_print(id, "[AMXX] Client ^"%s^" kicked", name2) | ||
246 : | |||
247 : | return PLUGIN_HANDLED | ||
248 : | } | ||
249 : | |||
250 : | public cmdUnban(id, level, cid) | ||
251 : | { | ||
252 : | if (!cmd_access(id, level, cid, 2)) | ||
253 : | return PLUGIN_HANDLED | ||
254 : | |||
255 : | new arg[32], authid[32], name[32] | ||
256 : | |||
257 : | read_argv(1, arg, 31) | ||
258 : | |||
259 : | if (contain(arg, ".") != -1) | ||
260 : | { | ||
261 : | server_cmd("removeip ^"%s^";writeip", arg) | ||
262 : | console_print(id, "[AMXX] %L", id, "IP_REMOVED", arg) | ||
263 : | } else { | ||
264 : | server_cmd("removeid %s;writeid", arg) | ||
265 : | console_print(id, "[AMXX] %L", id, "AUTHID_REMOVED", arg) | ||
266 : | } | ||
267 : | |||
268 : | get_user_name(id, name, 31) | ||
269 : | |||
270 : | ian | 17 | show_activity_key("ADMIN_UNBAN_1", "ADMIN_UNBAN_2", name, arg); |
271 : | |||
272 : | ian | 1 | get_user_authid(id, authid, 31) |
273 : | log_amx("Cmd: ^"%s<%d><%s><>^" unban ^"%s^"", name, get_user_userid(id), authid, arg) | ||
274 : | |||
275 : | return PLUGIN_HANDLED | ||
276 : | } | ||
277 : | |||
278 : | ian | 17 | /* amx_addban is a special command now. |
279 : | * If a user with rcon uses it, it bans the user. No questions asked. | ||
280 : | * If a user without rcon but with ADMIN_BAN uses it, it will scan the old | ||
281 : | * connection queue, and if it finds the info for a player in it, it will | ||
282 : | * check their old access. If they have immunity, it will not ban. | ||
283 : | * If they do not have immunity, it will ban. If the user is not found, | ||
284 : | * it will refuse to ban the target. | ||
285 : | */ | ||
286 : | |||
287 : | ian | 1 | public cmdAddBan(id, level, cid) |
288 : | { | ||
289 : | ian | 17 | if (!cmd_access(id, level, cid, 3, true)) // check for ADMIN_BAN access |
290 : | { | ||
291 : | if (get_user_flags(id) & level) // Getting here means they didn't input enough args | ||
292 : | { | ||
293 : | return PLUGIN_HANDLED; | ||
294 : | } | ||
295 : | if (!cmd_access(id, ADMIN_RCON, cid, 3)) // If somehow they have ADMIN_RCON without ADMIN_BAN, continue | ||
296 : | { | ||
297 : | return PLUGIN_HANDLED; | ||
298 : | } | ||
299 : | } | ||
300 : | ian | 1 | |
301 : | new arg[32], authid[32], name[32], minutes[32], reason[32] | ||
302 : | |||
303 : | read_argv(1, arg, 31) | ||
304 : | read_argv(2, minutes, 31) | ||
305 : | read_argv(3, reason, 31) | ||
306 : | |||
307 : | ian | 17 | |
308 : | if (!(get_user_flags(id) & ADMIN_RCON)) | ||
309 : | { | ||
310 : | new bool:canban = false; | ||
311 : | new bool:isip = false; | ||
312 : | // Limited access to this command | ||
313 : | if (equali(arg, "STEAM_ID_PENDING") || | ||
314 : | equali(arg, "STEAM_ID_LAN") || | ||
315 : | equali(arg, "HLTV") || | ||
316 : | equali(arg, "4294967295") || | ||
317 : | equali(arg, "VALVE_ID_LAN") || | ||
318 : | equali(arg, "VALVE_ID_PENDING")) | ||
319 : | { | ||
320 : | // Hopefully we never get here, so ML shouldn't be needed | ||
321 : | console_print(id, "Cannot ban %s", arg); | ||
322 : | return PLUGIN_HANDLED; | ||
323 : | } | ||
324 : | |||
325 : | if (contain(arg, ".") != -1) | ||
326 : | { | ||
327 : | isip = true; | ||
328 : | } | ||
329 : | |||
330 : | // Scan the disconnection queue | ||
331 : | if (isip) | ||
332 : | { | ||
333 : | new IP[32]; | ||
334 : | new Name[32]; | ||
335 : | new dummy[1]; | ||
336 : | new Access; | ||
337 : | for (new i = 0; i < g_Size; i++) | ||
338 : | { | ||
339 : | GetInfo(i, Name, charsmax(Name), dummy, 0, IP, charsmax(IP), Access); | ||
340 : | |||
341 : | if (equal(IP, arg)) | ||
342 : | { | ||
343 : | if (Access & ADMIN_IMMUNITY) | ||
344 : | { | ||
345 : | console_print(id, "[AMXX] %s : %L", IP, id, "CLIENT_IMM", Name); | ||
346 : | |||
347 : | return PLUGIN_HANDLED; | ||
348 : | } | ||
349 : | // User did not have immunity | ||
350 : | canban = true; | ||
351 : | } | ||
352 : | } | ||
353 : | } | ||
354 : | else | ||
355 : | { | ||
356 : | new Auth[32]; | ||
357 : | new Name[32]; | ||
358 : | new dummy[1]; | ||
359 : | new Access; | ||
360 : | for (new i = 0; i < g_Size; i++) | ||
361 : | { | ||
362 : | GetInfo(i, Name, charsmax(Name), Auth, charsmax(Auth), dummy, 0, Access); | ||
363 : | |||
364 : | if (equal(Auth, arg)) | ||
365 : | { | ||
366 : | if (Access & ADMIN_IMMUNITY) | ||
367 : | { | ||
368 : | console_print(id, "[AMXX] %s : %L", Auth, id, "CLIENT_IMM", Name); | ||
369 : | |||
370 : | return PLUGIN_HANDLED; | ||
371 : | } | ||
372 : | // User did not have immunity | ||
373 : | canban = true; | ||
374 : | } | ||
375 : | } | ||
376 : | } | ||
377 : | |||
378 : | if (!canban) | ||
379 : | { | ||
380 : | console_print(id, "[AMXX] You may only ban recently disconnected clients. Use ^"amx_last^" to view."); | ||
381 : | |||
382 : | return PLUGIN_HANDLED; | ||
383 : | } | ||
384 : | |||
385 : | } | ||
386 : | |||
387 : | // User has access to ban their target | ||
388 : | ian | 1 | if (contain(arg, ".") != -1) |
389 : | { | ||
390 : | server_cmd("addip ^"%s^" ^"%s^";wait;writeip", minutes, arg) | ||
391 : | console_print(id, "[AMXX] Ip ^"%s^" added to ban list", arg) | ||
392 : | } else { | ||
393 : | server_cmd("banid ^"%s^" ^"%s^";wait;writeid", minutes, arg) | ||
394 : | console_print(id, "[AMXX] Authid ^"%s^" added to ban list", arg) | ||
395 : | } | ||
396 : | |||
397 : | get_user_name(id, name, 31) | ||
398 : | |||
399 : | ian | 17 | show_activity_key("ADMIN_ADDBAN_1", "ADMIN_ADDBAN_2", name, arg); |
400 : | ian | 1 | |
401 : | get_user_authid(id, authid, 31) | ||
402 : | log_amx("Cmd: ^"%s<%d><%s><>^" ban ^"%s^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, arg, minutes, reason) | ||
403 : | |||
404 : | return PLUGIN_HANDLED | ||
405 : | } | ||
406 : | |||
407 : | public cmdBan(id, level, cid) | ||
408 : | { | ||
409 : | if (!cmd_access(id, level, cid, 3)) | ||
410 : | return PLUGIN_HANDLED | ||
411 : | |||
412 : | new target[32], minutes[8], reason[64] | ||
413 : | |||
414 : | read_argv(1, target, 31) | ||
415 : | read_argv(2, minutes, 7) | ||
416 : | read_argv(3, reason, 63) | ||
417 : | |||
418 : | ian | 17 | new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF) |
419 : | ian | 1 | |
420 : | if (!player) | ||
421 : | return PLUGIN_HANDLED | ||
422 : | |||
423 : | new authid[32], name2[32], authid2[32], name[32] | ||
424 : | new userid2 = get_user_userid(player) | ||
425 : | |||
426 : | get_user_authid(player, authid2, 31) | ||
427 : | get_user_authid(id, authid, 31) | ||
428 : | get_user_name(player, name2, 31) | ||
429 : | get_user_name(id, name, 31) | ||
430 : | |||
431 : | 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) | ||
432 : | |||
433 : | new temp[64], banned[16], nNum = str_to_num(minutes) | ||
434 : | if (nNum) | ||
435 : | format(temp, 63, "%L", player, "FOR_MIN", minutes) | ||
436 : | else | ||
437 : | format(temp, 63, "%L", player, "PERM") | ||
438 : | |||
439 : | format(banned, 15, "%L", player, "BANNED") | ||
440 : | |||
441 : | if (reason[0]) | ||
442 : | server_cmd("kick #%d ^"%s (%s %s)^";wait;banid ^"%s^" ^"%s^";wait;writeid", userid2, reason, banned, temp, minutes, authid2) | ||
443 : | else | ||
444 : | server_cmd("kick #%d ^"%s %s^";wait;banid ^"%s^" ^"%s^";wait;writeid", userid2, banned, temp, minutes, authid2) | ||
445 : | |||
446 : | ian | 17 | |
447 : | // Display the message to all clients | ||
448 : | |||
449 : | new msg[256]; | ||
450 : | new len; | ||
451 : | new maxpl = get_maxplayers(); | ||
452 : | for (new i = 1; i <= maxpl; i++) | ||
453 : | ian | 1 | { |
454 : | ian | 17 | if (is_user_connected(i) && !is_user_bot(i)) |
455 : | ian | 1 | { |
456 : | ian | 17 | len = formatex(msg, charsmax(msg), "%L", i, "BAN"); |
457 : | len += formatex(msg[len], charsmax(msg) - len, " %s ", name2); | ||
458 : | ian | 1 | if (nNum) |
459 : | ian | 17 | { |
460 : | ian | 44 | len += formatex(msg[len], charsmax(msg) - len, "%L", i, "FOR_MIN", minutes); |
461 : | ian | 17 | } |
462 : | ian | 1 | else |
463 : | ian | 17 | { |
464 : | ian | 44 | len += formatex(msg[len], charsmax(msg) - len, "%L", i, "PERM"); |
465 : | ian | 17 | } |
466 : | if (strlen(reason) > 0) | ||
467 : | { | ||
468 : | formatex(msg[len], charsmax(msg) - len, " (%L: %s)", i, "REASON", reason); | ||
469 : | } | ||
470 : | show_activity_id(i, id, name, msg); | ||
471 : | ian | 1 | } |
472 : | } | ||
473 : | ian | 17 | |
474 : | ian | 1 | console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2) |
475 : | |||
476 : | return PLUGIN_HANDLED | ||
477 : | } | ||
478 : | |||
479 : | public cmdBanIP(id, level, cid) | ||
480 : | { | ||
481 : | if (!cmd_access(id, level, cid, 3)) | ||
482 : | return PLUGIN_HANDLED | ||
483 : | |||
484 : | new target[32], minutes[8], reason[64] | ||
485 : | |||
486 : | read_argv(1, target, 31) | ||
487 : | read_argv(2, minutes, 7) | ||
488 : | read_argv(3, reason, 63) | ||
489 : | |||
490 : | ian | 17 | new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF) |
491 : | ian | 1 | |
492 : | if (!player) | ||
493 : | ian | 17 | { |
494 : | // why is this here? | ||
495 : | ian | 44 | // no idea |
496 : | // player = cmd_target(id, target, 9); | ||
497 : | ian | 1 | return PLUGIN_HANDLED |
498 : | ian | 17 | } |
499 : | ian | 1 | |
500 : | new authid[32], name2[32], authid2[32], name[32] | ||
501 : | new userid2 = get_user_userid(player) | ||
502 : | |||
503 : | get_user_authid(player, authid2, 31) | ||
504 : | get_user_authid(id, authid, 31) | ||
505 : | get_user_name(player, name2, 31) | ||
506 : | get_user_name(id, name, 31) | ||
507 : | |||
508 : | 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) | ||
509 : | |||
510 : | new temp[64], banned[16], nNum = str_to_num(minutes) | ||
511 : | if (nNum) | ||
512 : | format(temp, 63, "%L", player, "FOR_MIN", minutes) | ||
513 : | else | ||
514 : | format(temp, 63, "%L", player, "PERM") | ||
515 : | format(banned, 15, "%L", player, "BANNED") | ||
516 : | |||
517 : | new address[32] | ||
518 : | get_user_ip(player, address, 31, 1) | ||
519 : | |||
520 : | if (reason[0]) | ||
521 : | server_cmd("kick #%d ^"%s (%s %s)^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, reason, banned, temp, minutes, address) | ||
522 : | else | ||
523 : | server_cmd("kick #%d ^"%s %s^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, banned, temp, minutes, address) | ||
524 : | |||
525 : | ian | 17 | // Display the message to all clients |
526 : | |||
527 : | new msg[256]; | ||
528 : | new len; | ||
529 : | new maxpl = get_maxplayers(); | ||
530 : | for (new i = 1; i <= maxpl; i++) | ||
531 : | ian | 1 | { |
532 : | ian | 17 | if (is_user_connected(i) && !is_user_bot(i)) |
533 : | ian | 1 | { |
534 : | ian | 17 | len = formatex(msg, charsmax(msg), "%L", i, "BAN"); |
535 : | len += formatex(msg[len], charsmax(msg) - len, " %s ", name2); | ||
536 : | ian | 1 | if (nNum) |
537 : | ian | 17 | { |
538 : | formatex(msg[len], charsmax(msg) - len, "%L", i, "FOR_MIN", minutes); | ||
539 : | } | ||
540 : | ian | 1 | else |
541 : | ian | 17 | { |
542 : | formatex(msg[len], charsmax(msg) - len, "%L", i, "PERM"); | ||
543 : | } | ||
544 : | if (strlen(reason) > 0) | ||
545 : | { | ||
546 : | formatex(msg[len], charsmax(msg) - len, " (%L: %s)", i, "REASON", reason); | ||
547 : | } | ||
548 : | show_activity_id(i, id, name, msg); | ||
549 : | ian | 1 | } |
550 : | } | ||
551 : | ian | 17 | |
552 : | ian | 1 | console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2) |
553 : | |||
554 : | return PLUGIN_HANDLED | ||
555 : | } | ||
556 : | |||
557 : | public cmdSlay(id, level, cid) | ||
558 : | { | ||
559 : | if (!cmd_access(id, level, cid, 2)) | ||
560 : | return PLUGIN_HANDLED | ||
561 : | |||
562 : | new arg[32] | ||
563 : | |||
564 : | read_argv(1, arg, 31) | ||
565 : | |||
566 : | ian | 17 | new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE) |
567 : | ian | 1 | |
568 : | if (!player) | ||
569 : | return PLUGIN_HANDLED | ||
570 : | |||
571 : | user_kill(player) | ||
572 : | |||
573 : | new authid[32], name2[32], authid2[32], name[32] | ||
574 : | |||
575 : | get_user_authid(id, authid, 31) | ||
576 : | get_user_name(id, name, 31) | ||
577 : | get_user_authid(player, authid2, 31) | ||
578 : | get_user_name(player, name2, 31) | ||
579 : | |||
580 : | log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2) | ||
581 : | |||
582 : | ian | 17 | show_activity_key("ADMIN_SLAY_1", "ADMIN_SLAY_2", name, name2); |
583 : | |||
584 : | ian | 1 | console_print(id, "[AMXX] %L", id, "CLIENT_SLAYED", name2) |
585 : | |||
586 : | return PLUGIN_HANDLED | ||
587 : | } | ||
588 : | |||
589 : | public cmdSlap(id, level, cid) | ||
590 : | { | ||
591 : | if (!cmd_access(id, level, cid, 2)) | ||
592 : | return PLUGIN_HANDLED | ||
593 : | |||
594 : | new arg[32] | ||
595 : | |||
596 : | read_argv(1, arg, 31) | ||
597 : | ian | 17 | new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE) |
598 : | ian | 1 | |
599 : | if (!player) | ||
600 : | return PLUGIN_HANDLED | ||
601 : | |||
602 : | new spower[32], authid[32], name2[32], authid2[32], name[32] | ||
603 : | |||
604 : | read_argv(2, spower, 31) | ||
605 : | |||
606 : | new damage = str_to_num(spower) | ||
607 : | |||
608 : | user_slap(player, damage) | ||
609 : | |||
610 : | get_user_authid(id, authid, 31) | ||
611 : | get_user_name(id, name, 31) | ||
612 : | get_user_authid(player, authid2, 31) | ||
613 : | get_user_name(player, name2, 31) | ||
614 : | |||
615 : | 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) | ||
616 : | |||
617 : | ian | 17 | show_activity_key("ADMIN_SLAP_1", "ADMIN_SLAP_2", name, name2, damage); |
618 : | |||
619 : | ian | 1 | console_print(id, "[AMXX] %L", id, "CLIENT_SLAPED", name2, damage) |
620 : | |||
621 : | return PLUGIN_HANDLED | ||
622 : | } | ||
623 : | |||
624 : | public chMap(map[]) | ||
625 : | { | ||
626 : | server_cmd("changelevel %s", map) | ||
627 : | } | ||
628 : | |||
629 : | public cmdMap(id, level, cid) | ||
630 : | { | ||
631 : | if (!cmd_access(id, level, cid, 2)) | ||
632 : | return PLUGIN_HANDLED | ||
633 : | |||
634 : | new arg[32] | ||
635 : | new arglen = read_argv(1, arg, 31) | ||
636 : | |||
637 : | if (!is_map_valid(arg)) | ||
638 : | { | ||
639 : | console_print(id, "[AMXX] %L", id, "MAP_NOT_FOUND") | ||
640 : | return PLUGIN_HANDLED | ||
641 : | } | ||
642 : | |||
643 : | new authid[32], name[32] | ||
644 : | |||
645 : | get_user_authid(id, authid, 31) | ||
646 : | get_user_name(id, name, 31) | ||
647 : | |||
648 : | ian | 17 | show_activity_key("ADMIN_MAP_1", "ADMIN_MAP_2", name, arg); |
649 : | ian | 1 | |
650 : | log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", name, get_user_userid(id), authid, arg) | ||
651 : | |||
652 : | new _modName[10] | ||
653 : | get_modname(_modName, 9) | ||
654 : | |||
655 : | if (!equal(_modName, "zp")) | ||
656 : | { | ||
657 : | message_begin(MSG_ALL, SVC_INTERMISSION) | ||
658 : | message_end() | ||
659 : | } | ||
660 : | |||
661 : | set_task(2.0, "chMap", 0, arg, arglen + 1) | ||
662 : | |||
663 : | return PLUGIN_HANDLED | ||
664 : | } | ||
665 : | |||
666 : | ian | 17 | stock bool:onlyRcon(const name[]) |
667 : | ian | 1 | { |
668 : | ian | 17 | new ptr=get_cvar_pointer(name); |
669 : | if (ptr && get_pcvar_flags(ptr) & FCVAR_PROTECTED) | ||
670 : | { | ||
671 : | return true; | ||
672 : | } | ||
673 : | return false; | ||
674 : | ian | 1 | } |
675 : | |||
676 : | public cmdCvar(id, level, cid) | ||
677 : | { | ||
678 : | if (!cmd_access(id, level, cid, 2)) | ||
679 : | return PLUGIN_HANDLED | ||
680 : | |||
681 : | new arg[32], arg2[64] | ||
682 : | |||
683 : | read_argv(1, arg, 31) | ||
684 : | read_argv(2, arg2, 63) | ||
685 : | |||
686 : | ian | 17 | new pointer; |
687 : | |||
688 : | ian | 1 | if (equal(arg, "add") && (get_user_flags(id) & ADMIN_RCON)) |
689 : | { | ||
690 : | ian | 17 | if ((pointer=get_cvar_pointer(arg2))!=0) |
691 : | ian | 1 | { |
692 : | ian | 17 | new flags=get_pcvar_flags(pointer); |
693 : | |||
694 : | if (!(flags & FCVAR_PROTECTED)) | ||
695 : | { | ||
696 : | set_pcvar_flags(pointer,flags | FCVAR_PROTECTED); | ||
697 : | } | ||
698 : | ian | 1 | } |
699 : | return PLUGIN_HANDLED | ||
700 : | } | ||
701 : | |||
702 : | ian | 17 | if ((pointer=get_cvar_pointer(arg))==0) |
703 : | ian | 1 | { |
704 : | console_print(id, "[AMXX] %L", id, "UNKNOWN_CVAR", arg) | ||
705 : | return PLUGIN_HANDLED | ||
706 : | } | ||
707 : | |||
708 : | if (onlyRcon(arg) && !(get_user_flags(id) & ADMIN_RCON)) | ||
709 : | { | ||
710 : | ian | 17 | // Exception for the new onlyRcon rules: |
711 : | // sv_password is allowed to be modified by ADMIN_PASSWORD | ||
712 : | if (!(equali(arg,"sv_password") && (get_user_flags(id) & ADMIN_PASSWORD))) | ||
713 : | { | ||
714 : | console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC") | ||
715 : | return PLUGIN_HANDLED | ||
716 : | } | ||
717 : | ian | 1 | } |
718 : | |||
719 : | if (read_argc() < 3) | ||
720 : | { | ||
721 : | ian | 17 | get_pcvar_string(pointer, arg2, 63) |
722 : | ian | 1 | console_print(id, "[AMXX] %L", id, "CVAR_IS", arg, arg2) |
723 : | return PLUGIN_HANDLED | ||
724 : | } | ||
725 : | |||
726 : | new authid[32], name[32] | ||
727 : | |||
728 : | get_user_authid(id, authid, 31) | ||
729 : | get_user_name(id, name, 31) | ||
730 : | |||
731 : | log_amx("Cmd: ^"%s<%d><%s><>^" set cvar (name ^"%s^") (value ^"%s^")", name, get_user_userid(id), authid, arg, arg2) | ||
732 : | set_cvar_string(arg, arg2) | ||
733 : | ian | 17 | |
734 : | |||
735 : | // Display the message to all clients | ||
736 : | ian | 1 | |
737 : | ian | 17 | new cvar_val[64]; |
738 : | new maxpl = get_maxplayers(); | ||
739 : | for (new i = 1; i <= maxpl; i++) | ||
740 : | ian | 1 | { |
741 : | ian | 17 | if (is_user_connected(i) && !is_user_bot(i)) |
742 : | ian | 1 | { |
743 : | ian | 17 | if (get_pcvar_flags(pointer) & FCVAR_PROTECTED || equali(arg, "rcon_password")) |
744 : | { | ||
745 : | formatex(cvar_val, charsmax(cvar_val), "*** %L ***", i, "PROTECTED"); | ||
746 : | } | ||
747 : | ian | 1 | else |
748 : | ian | 17 | { |
749 : | copy(cvar_val, charsmax(cvar_val), arg2); | ||
750 : | } | ||
751 : | show_activity_id(i, id, name, "%L", i, "SET_CVAR_TO", "", arg, cvar_val); | ||
752 : | ian | 1 | } |
753 : | } | ||
754 : | ian | 17 | |
755 : | ian | 1 | console_print(id, "[AMXX] %L", id, "CVAR_CHANGED", arg, arg2) |
756 : | |||
757 : | return PLUGIN_HANDLED | ||
758 : | } | ||
759 : | |||
760 : | public cmdPlugins(id, level, cid) | ||
761 : | { | ||
762 : | if (!cmd_access(id, level, cid, 1)) | ||
763 : | return PLUGIN_HANDLED | ||
764 : | ian | 17 | |
765 : | if (id==0) // If server executes redirect this to "amxx plugins" for more in depth output | ||
766 : | { | ||
767 : | server_cmd("amxx plugins"); | ||
768 : | server_exec(); | ||
769 : | return PLUGIN_HANDLED; | ||
770 : | } | ||
771 : | ian | 1 | |
772 : | new name[32], version[32], author[32], filename[32], status[32] | ||
773 : | new lName[32], lVersion[32], lAuthor[32], lFile[32], lStatus[32] | ||
774 : | |||
775 : | format(lName, 31, "%L", id, "NAME") | ||
776 : | format(lVersion, 31, "%L", id, "VERSION") | ||
777 : | format(lAuthor, 31, "%L", id, "AUTHOR") | ||
778 : | format(lFile, 31, "%L", id, "FILE") | ||
779 : | format(lStatus, 31, "%L", id, "STATUS") | ||
780 : | |||
781 : | ian | 17 | new StartPLID=0; |
782 : | new EndPLID; | ||
783 : | |||
784 : | new Temp[96] | ||
785 : | |||
786 : | ian | 1 | new num = get_pluginsnum() |
787 : | ian | 17 | |
788 : | if (read_argc() > 1) | ||
789 : | { | ||
790 : | read_argv(1,Temp,sizeof(Temp)-1); | ||
791 : | StartPLID=str_to_num(Temp)-1; // zero-based | ||
792 : | } | ||
793 : | |||
794 : | EndPLID=min(StartPLID + 10, num); | ||
795 : | |||
796 : | ian | 1 | new running = 0 |
797 : | |||
798 : | ian | 17 | console_print(id, "----- %L -----", id, "LOADED_PLUGINS") |
799 : | console_print(id, "%-18.17s %-11.10s %-17.16s %-16.15s %-9.8s", lName, lVersion, lAuthor, lFile, lStatus) | ||
800 : | ian | 1 | |
801 : | ian | 17 | new i=StartPLID; |
802 : | while (i <EndPLID) | ||
803 : | ian | 1 | { |
804 : | ian | 17 | get_plugin(i++, filename, 31, name, 31, version, 31, author, 31, status, 31) |
805 : | console_print(id, "%-18.17s %-11.10s %-17.16s %-16.15s %-9.8s", name, version, author, filename, status) | ||
806 : | ian | 1 | |
807 : | if (status[0]=='d' || status[0]=='r') // "debug" or "running" | ||
808 : | running++ | ||
809 : | } | ||
810 : | ian | 17 | console_print(id, "%L", id, "PLUGINS_RUN", EndPLID-StartPLID, running) |
811 : | console_print(id, "----- %L -----",id,"HELP_ENTRIES",StartPLID + 1,EndPLID,num); | ||
812 : | |||
813 : | if (EndPLID < num) | ||
814 : | { | ||
815 : | formatex(Temp,sizeof(Temp)-1,"----- %L -----",id,"HELP_USE_MORE", EndPLID + 1); | ||
816 : | replace_all(Temp,sizeof(Temp)-1,"amx_help","amx_plugins"); | ||
817 : | console_print(id,"%s",Temp); | ||
818 : | } | ||
819 : | else | ||
820 : | { | ||
821 : | formatex(Temp,sizeof(Temp)-1,"----- %L -----",id,"HELP_USE_BEGIN"); | ||
822 : | replace_all(Temp,sizeof(Temp)-1,"amx_help","amx_plugins"); | ||
823 : | console_print(id,"%s",Temp); | ||
824 : | } | ||
825 : | ian | 1 | |
826 : | return PLUGIN_HANDLED | ||
827 : | } | ||
828 : | |||
829 : | public cmdModules(id, level, cid) | ||
830 : | { | ||
831 : | if (!cmd_access(id, level, cid, 1)) | ||
832 : | return PLUGIN_HANDLED | ||
833 : | |||
834 : | new name[32], version[32], author[32], status, sStatus[16] | ||
835 : | ian | 17 | new lName[32], lVersion[32], lAuthor[32], lStatus[32]; |
836 : | ian | 1 | |
837 : | format(lName, 31, "%L", id, "NAME") | ||
838 : | format(lVersion, 31, "%L", id, "VERSION") | ||
839 : | format(lAuthor, 31, "%L", id, "AUTHOR") | ||
840 : | ian | 17 | format(lStatus, charsmax(lStatus), "%L", id, "STATUS") |
841 : | ian | 1 | |
842 : | new num = get_modulesnum() | ||
843 : | |||
844 : | console_print(id, "%L:", id, "LOADED_MODULES") | ||
845 : | ian | 17 | console_print(id, "%-23.22s %-11.10s %-20.19s %-11.10s", lName, lVersion, lAuthor, lStatus) |
846 : | ian | 1 | |
847 : | for (new i = 0; i < num; i++) | ||
848 : | { | ||
849 : | get_module(i, name, 31, author, 31, version, 31, status) | ||
850 : | |||
851 : | switch (status) | ||
852 : | { | ||
853 : | case module_loaded: copy(sStatus, 15, "running") | ||
854 : | ian | 17 | default: |
855 : | { | ||
856 : | copy(sStatus, 15, "bad load"); | ||
857 : | copy(name, charsmax(name), "unknown"); | ||
858 : | copy(author, charsmax(author), "unknown"); | ||
859 : | copy(version, charsmax(version), "unknown"); | ||
860 : | } | ||
861 : | ian | 1 | } |
862 : | |||
863 : | ian | 17 | console_print(id, "%-23.22s %-11.10s %-20.19s %-11.10s", name, version, author, sStatus) |
864 : | ian | 1 | } |
865 : | console_print(id, "%L", id, "NUM_MODULES", num) | ||
866 : | |||
867 : | return PLUGIN_HANDLED | ||
868 : | } | ||
869 : | |||
870 : | public cmdCfg(id, level, cid) | ||
871 : | { | ||
872 : | if (!cmd_access(id, level, cid, 2)) | ||
873 : | return PLUGIN_HANDLED | ||
874 : | |||
875 : | new arg[128] | ||
876 : | read_argv(1, arg, 127) | ||
877 : | |||
878 : | if (!file_exists(arg)) | ||
879 : | { | ||
880 : | console_print(id, "[AMXX] %L", id, "FILE_NOT_FOUND", arg) | ||
881 : | return PLUGIN_HANDLED | ||
882 : | } | ||
883 : | |||
884 : | new authid[32], name[32] | ||
885 : | |||
886 : | get_user_authid(id, authid, 31) | ||
887 : | get_user_name(id, name, 31) | ||
888 : | |||
889 : | log_amx("Cmd: ^"%s<%d><%s><>^" execute cfg (file ^"%s^")", name, get_user_userid(id), authid, arg) | ||
890 : | |||
891 : | console_print(id, "[AMXX] Executing file ^"%s^"", arg) | ||
892 : | server_cmd("exec %s", arg) | ||
893 : | |||
894 : | ian | 17 | show_activity_key("ADMIN_CONF_1", "ADMIN_CONF_2", name, arg); |
895 : | ian | 1 | |
896 : | return PLUGIN_HANDLED | ||
897 : | } | ||
898 : | |||
899 : | public cmdLBack() | ||
900 : | { | ||
901 : | if (!g_PauseAllowed) | ||
902 : | return PLUGIN_CONTINUE | ||
903 : | |||
904 : | new paused[25] | ||
905 : | |||
906 : | format(paused, 24, "%L", g_pauseCon, g_Paused ? "UNPAUSED" : "PAUSED") | ||
907 : | set_cvar_float("pausable", g_pausAble) | ||
908 : | console_print(g_pauseCon, "[AMXX] Server %s", paused) | ||
909 : | g_PauseAllowed = false | ||
910 : | |||
911 : | if (g_Paused) | ||
912 : | g_Paused = false | ||
913 : | else | ||
914 : | g_Paused = true | ||
915 : | |||
916 : | return PLUGIN_HANDLED | ||
917 : | } | ||
918 : | |||
919 : | public cmdPause(id, level, cid) | ||
920 : | { | ||
921 : | if (!cmd_access(id, level, cid, 1)) | ||
922 : | return PLUGIN_HANDLED | ||
923 : | |||
924 : | new authid[32], name[32], slayer = id | ||
925 : | |||
926 : | get_user_authid(id, authid, 31) | ||
927 : | get_user_name(id, name, 31) | ||
928 : | ian | 17 | if (pausable!=0) |
929 : | { | ||
930 : | g_pausAble = get_pcvar_float(pausable) | ||
931 : | } | ||
932 : | ian | 1 | |
933 : | if (!slayer) | ||
934 : | slayer = find_player("h") | ||
935 : | |||
936 : | if (!slayer) | ||
937 : | { | ||
938 : | console_print(id, "[AMXX] %L", id, "UNABLE_PAUSE") | ||
939 : | return PLUGIN_HANDLED | ||
940 : | } | ||
941 : | |||
942 : | set_cvar_float("pausable", 1.0) | ||
943 : | g_PauseAllowed = true | ||
944 : | client_cmd(slayer, "pause;pauseAck") | ||
945 : | |||
946 : | log_amx("Cmd: ^"%s<%d><%s><>^" %s server", name, get_user_userid(id), authid, g_Paused ? "unpause" : "pause") | ||
947 : | |||
948 : | console_print(id, "[AMXX] %L", id, g_Paused ? "UNPAUSING" : "PAUSING") | ||
949 : | |||
950 : | ian | 17 | // Display the message to all clients |
951 : | |||
952 : | new maxpl = get_maxplayers(); | ||
953 : | for (new i = 1; i <= maxpl; i++) | ||
954 : | ian | 1 | { |
955 : | ian | 17 | if (is_user_connected(i) && !is_user_bot(i)) |
956 : | ian | 1 | { |
957 : | ian | 17 | show_activity_id(i, id, name, "%L server", i, g_Paused ? "UNPAUSE" : "PAUSE"); |
958 : | ian | 1 | } |
959 : | } | ||
960 : | ian | 17 | |
961 : | ian | 1 | g_pauseCon = id |
962 : | |||
963 : | return PLUGIN_HANDLED | ||
964 : | } | ||
965 : | |||
966 : | public cmdShowRcon(id, level, cid) | ||
967 : | { | ||
968 : | if (!cmd_access(id, level, cid, 2)) | ||
969 : | return PLUGIN_HANDLED | ||
970 : | |||
971 : | new password[64] | ||
972 : | |||
973 : | ian | 17 | get_pcvar_string(rcon_password, password, 63) |
974 : | ian | 1 | |
975 : | if (!password[0]) | ||
976 : | { | ||
977 : | cmdRcon(id, level, cid) | ||
978 : | } else { | ||
979 : | new args[128] | ||
980 : | |||
981 : | read_args(args, 127) | ||
982 : | client_cmd(id, "rcon_password %s", password) | ||
983 : | client_cmd(id, "rcon %s", args) | ||
984 : | } | ||
985 : | |||
986 : | return PLUGIN_HANDLED | ||
987 : | } | ||
988 : | |||
989 : | public cmdRcon(id, level, cid) | ||
990 : | { | ||
991 : | if (!cmd_access(id, level, cid, 2)) | ||
992 : | return PLUGIN_HANDLED | ||
993 : | |||
994 : | new arg[128], authid[32], name[32] | ||
995 : | |||
996 : | read_args(arg, 127) | ||
997 : | get_user_authid(id, authid, 31) | ||
998 : | get_user_name(id, name, 31) | ||
999 : | |||
1000 : | log_amx("Cmd: ^"%s<%d><%s><>^" server console (cmdline ^"%s^")", name, get_user_userid(id), authid, arg) | ||
1001 : | |||
1002 : | console_print(id, "[AMXX] %L", id, "COM_SENT_SERVER", arg) | ||
1003 : | server_cmd("%s", arg) | ||
1004 : | |||
1005 : | return PLUGIN_HANDLED | ||
1006 : | } | ||
1007 : | |||
1008 : | public cmdWho(id, level, cid) | ||
1009 : | { | ||
1010 : | if (!cmd_access(id, level, cid, 1)) | ||
1011 : | return PLUGIN_HANDLED | ||
1012 : | |||
1013 : | new players[32], inum, cl_on_server[64], authid[32], name[32], flags, sflags[32] | ||
1014 : | new lImm[16], lRes[16], lAccess[16], lYes[16], lNo[16] | ||
1015 : | |||
1016 : | format(lImm, 15, "%L", id, "IMMU") | ||
1017 : | format(lRes, 15, "%L", id, "RESERV") | ||
1018 : | format(lAccess, 15, "%L", id, "ACCESS") | ||
1019 : | format(lYes, 15, "%L", id, "YES") | ||
1020 : | format(lNo, 15, "%L", id, "NO") | ||
1021 : | |||
1022 : | get_players(players, inum) | ||
1023 : | format(cl_on_server, 63, "%L", id, "CLIENTS_ON_SERVER") | ||
1024 : | console_print(id, "^n%s:^n # %-16.15s %-20s %-8s %-4.3s %-4.3s %s", cl_on_server, "nick", "authid", "userid", lImm, lRes, lAccess) | ||
1025 : | |||
1026 : | for (new a = 0; a < inum; ++a) | ||
1027 : | { | ||
1028 : | get_user_authid(players[a], authid, 31) | ||
1029 : | get_user_name(players[a], name, 31) | ||
1030 : | flags = get_user_flags(players[a]) | ||
1031 : | get_flags(flags, sflags, 31) | ||
1032 : | console_print(id, "%2d %-16.15s %-20s %-8d %-6.5s %-6.5s %s", players[a], name, authid, | ||
1033 : | get_user_userid(players[a]), (flags&ADMIN_IMMUNITY) ? lYes : lNo, (flags&ADMIN_RESERVATION) ? lYes : lNo, sflags) | ||
1034 : | } | ||
1035 : | |||
1036 : | console_print(id, "%L", id, "TOTAL_NUM", inum) | ||
1037 : | get_user_authid(id, authid, 31) | ||
1038 : | get_user_name(id, name, 31) | ||
1039 : | log_amx("Cmd: ^"%s<%d><%s><>^" ask for players list", name, get_user_userid(id), authid) | ||
1040 : | |||
1041 : | return PLUGIN_HANDLED | ||
1042 : | } | ||
1043 : | |||
1044 : | hasTag(name[], tags[4][32], tagsNum) | ||
1045 : | { | ||
1046 : | for (new a = 0; a < tagsNum; ++a) | ||
1047 : | if (contain(name, tags[a]) != -1) | ||
1048 : | return a | ||
1049 : | return -1 | ||
1050 : | } | ||
1051 : | |||
1052 : | public cmdLeave(id, level, cid) | ||
1053 : | { | ||
1054 : | if (!cmd_access(id, level, cid, 2)) | ||
1055 : | return PLUGIN_HANDLED | ||
1056 : | |||
1057 : | new argnum = read_argc() | ||
1058 : | new ltags[4][32] | ||
1059 : | new ltagsnum = 0 | ||
1060 : | |||
1061 : | for (new a = 1; a < 5; ++a) | ||
1062 : | { | ||
1063 : | if (a < argnum) | ||
1064 : | read_argv(a, ltags[ltagsnum++], 31) | ||
1065 : | else | ||
1066 : | ltags[ltagsnum++][0] = 0 | ||
1067 : | } | ||
1068 : | |||
1069 : | new nick[32], ires, pnum = get_maxplayers() + 1, count = 0, lReason[128] | ||
1070 : | |||
1071 : | for (new b = 1; b < pnum; ++b) | ||
1072 : | { | ||
1073 : | if (!is_user_connected(b) && !is_user_connecting(b)) continue | ||
1074 : | |||
1075 : | get_user_name(b, nick, 31) | ||
1076 : | ires = hasTag(nick, ltags, ltagsnum) | ||
1077 : | |||
1078 : | if (ires != -1) | ||
1079 : | { | ||
1080 : | console_print(id, "[AMXX] %L", id, "SKIP_MATCH", nick, ltags[ires]) | ||
1081 : | continue | ||
1082 : | } | ||
1083 : | |||
1084 : | if (get_user_flags(b) & ADMIN_IMMUNITY) | ||
1085 : | { | ||
1086 : | console_print(id, "[AMXX] %L", id, "SKIP_IMM", nick) | ||
1087 : | continue | ||
1088 : | } | ||
1089 : | |||
1090 : | console_print(id, "[AMXX] %L", id, "KICK_PL", nick) | ||
1091 : | |||
1092 : | if (is_user_bot(b)) | ||
1093 : | server_cmd("kick #%d", get_user_userid(b)) | ||
1094 : | else | ||
1095 : | { | ||
1096 : | format(lReason, 127, "%L", b, "YOU_DROPPED") | ||
1097 : | server_cmd("kick #%d ^"%s^"", get_user_userid(b), lReason) | ||
1098 : | } | ||
1099 : | count++ | ||
1100 : | } | ||
1101 : | |||
1102 : | console_print(id, "[AMXX] %L", id, "KICKED_CLIENTS", count) | ||
1103 : | |||
1104 : | new authid[32], name[32] | ||
1105 : | |||
1106 : | get_user_authid(id, authid, 31) | ||
1107 : | get_user_name(id, name, 31) | ||
1108 : | 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]) | ||
1109 : | |||
1110 : | ian | 17 | show_activity_key("ADMIN_LEAVE_1", "ADMIN_LEAVE_2", name, ltags[0], ltags[1], ltags[2], ltags[3]); |
1111 : | ian | 1 | |
1112 : | return PLUGIN_HANDLED | ||
1113 : | } | ||
1114 : | |||
1115 : | public cmdNick(id, level, cid) | ||
1116 : | { | ||
1117 : | if (!cmd_access(id, level, cid, 3)) | ||
1118 : | return PLUGIN_HANDLED | ||
1119 : | |||
1120 : | new arg1[32], arg2[32], authid[32], name[32], authid2[32], name2[32] | ||
1121 : | |||
1122 : | read_argv(1, arg1, 31) | ||
1123 : | read_argv(2, arg2, 31) | ||
1124 : | |||
1125 : | ian | 17 | new player = cmd_target(id, arg1, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF) |
1126 : | ian | 1 | |
1127 : | if (!player) | ||
1128 : | return PLUGIN_HANDLED | ||
1129 : | |||
1130 : | get_user_authid(id, authid, 31) | ||
1131 : | get_user_name(id, name, 31) | ||
1132 : | get_user_authid(player, authid2, 31) | ||
1133 : | get_user_name(player, name2, 31) | ||
1134 : | |||
1135 : | client_cmd(player, "name ^"%s^"", arg2) | ||
1136 : | |||
1137 : | 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) | ||
1138 : | |||
1139 : | ian | 17 | show_activity_key("ADMIN_NICK_1", "ADMIN_NICK_2", name, name2, arg2); |
1140 : | |||
1141 : | ian | 1 | console_print(id, "[AMXX] %L", id, "CHANGED_NICK", name2, arg2) |
1142 : | |||
1143 : | return PLUGIN_HANDLED | ||
1144 : | } | ||
1145 : | ian | 17 | |
1146 : | public cmdLast(id, level, cid) | ||
1147 : | { | ||
1148 : | if (!cmd_access(id, level, cid, 1)) | ||
1149 : | { | ||
1150 : | return PLUGIN_HANDLED; | ||
1151 : | } | ||
1152 : | |||
1153 : | new name[32]; | ||
1154 : | new authid[32]; | ||
1155 : | new ip[32]; | ||
1156 : | new flags[32]; | ||
1157 : | new access; | ||
1158 : | |||
1159 : | |||
1160 : | // This alignment is a bit weird (it should grow if the name is larger) | ||
1161 : | // but otherwise for the more common shorter name, it'll wrap in server console | ||
1162 : | // Steam client display is all skewed anyway because of the non fixed font. | ||
1163 : | console_print(id, "%19s %20s %15s %s", "name", "authid", "ip", "access"); | ||
1164 : | |||
1165 : | for (new i = 0; i < g_Size; i++) | ||
1166 : | { | ||
1167 : | GetInfo(i, name, charsmax(name), authid, charsmax(authid), ip, charsmax(ip), access); | ||
1168 : | |||
1169 : | get_flags(access, flags, charsmax(flags)); | ||
1170 : | |||
1171 : | console_print(id, "%19s %20s %15s %s", name, authid, ip, flags); | ||
1172 : | } | ||
1173 : | |||
1174 : | console_print(id, "%d old connections saved.", g_Size); | ||
1175 : | |||
1176 : | return PLUGIN_HANDLED; | ||
1177 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |