Guest User

Untitled

a guest
Jun 24th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.63 KB | None | 0 0
  1. // vim: set ts=4 sw=4 tw=99 noet:
  2. //
  3. // AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
  4. // Copyright (C) The AMX Mod X Development Team.
  5. //
  6. // This software is licensed under the GNU General Public License, version 3 or higher.
  7. // Additional exceptions apply. For full license details, see LICENSE.txt or visit:
  8. // https://alliedmods.net/amxmodx-license
  9.  
  10. //
  11. // Admin Commands Plugin
  12. //
  13.  
  14. #include <amxmodx>
  15. #include <amxmisc>
  16. #include <cromchat>
  17.  
  18. // This is not a dynamic array because it would be bad for 24/7 map servers.
  19. #define OLD_CONNECTION_QUEUE 10
  20.  
  21. new g_pauseCon
  22. new Float:g_pausAble
  23. new bool:g_Paused
  24. new bool:g_PauseAllowed = false
  25.  
  26. new pausable;
  27. new rcon_password;
  28. new timelimit;
  29. new p_amx_tempban_maxtime;
  30.  
  31. // Old connection queue
  32. new g_Names[OLD_CONNECTION_QUEUE][MAX_NAME_LENGTH];
  33. new g_SteamIDs[OLD_CONNECTION_QUEUE][32];
  34. new g_IPs[OLD_CONNECTION_QUEUE][32];
  35. new g_Access[OLD_CONNECTION_QUEUE];
  36. new g_Tracker;
  37. new g_Size;
  38.  
  39. public Trie:g_tempBans
  40. new Trie:g_tXvarsFlags;
  41.  
  42. stock InsertInfo(id)
  43. {
  44.  
  45. // Scan to see if this entry is the last entry in the list
  46. // If it is, then update the name and access
  47. // If it is not, then insert it again.
  48.  
  49. if (g_Size > 0)
  50. {
  51. new ip[32]
  52. new auth[32];
  53.  
  54. get_user_authid(id, auth, charsmax(auth));
  55. get_user_ip(id, ip, charsmax(ip), 1/*no port*/);
  56.  
  57. new last = 0;
  58.  
  59. if (g_Size < sizeof(g_SteamIDs))
  60. {
  61. last = g_Size - 1;
  62. }
  63. else
  64. {
  65. last = g_Tracker - 1;
  66.  
  67. if (last < 0)
  68. {
  69. last = g_Size - 1;
  70. }
  71. }
  72.  
  73. if (equal(auth, g_SteamIDs[last]) &&
  74. equal(ip, g_IPs[last])) // need to check ip too, or all the nosteams will while it doesn't work with their illegitimate server
  75. {
  76. get_user_name(id, g_Names[last], charsmax(g_Names[]));
  77. g_Access[last] = get_user_flags(id);
  78.  
  79. return;
  80. }
  81. }
  82.  
  83. // Need to insert the entry
  84.  
  85. new target = 0; // the slot to save the info at
  86.  
  87. // Queue is not yet full
  88. if (g_Size < sizeof(g_SteamIDs))
  89. {
  90. target = g_Size;
  91.  
  92. ++g_Size;
  93.  
  94. }
  95. else
  96. {
  97. target = g_Tracker;
  98.  
  99. ++g_Tracker;
  100. // If we reached the end of the array, then move to the front
  101. if (g_Tracker == sizeof(g_SteamIDs))
  102. {
  103. g_Tracker = 0;
  104. }
  105. }
  106.  
  107. get_user_authid(id, g_SteamIDs[target], charsmax(g_SteamIDs[]));
  108. get_user_name(id, g_Names[target], charsmax(g_Names[]));
  109. get_user_ip(id, g_IPs[target], charsmax(g_IPs[]), 1/*no port*/);
  110.  
  111. g_Access[target] = get_user_flags(id);
  112.  
  113. }
  114. stock GetInfo(i, name[], namesize, auth[], authsize, ip[], ipsize, &access)
  115. {
  116. if (i >= g_Size)
  117. {
  118. abort(AMX_ERR_NATIVE, "GetInfo: Out of bounds (%d:%d)", i, g_Size);
  119. }
  120.  
  121. new target = (g_Tracker + i) % sizeof(g_SteamIDs);
  122.  
  123. copy(name, namesize, g_Names[target]);
  124. copy(auth, authsize, g_SteamIDs[target]);
  125. copy(ip, ipsize, g_IPs[target]);
  126. access = g_Access[target];
  127.  
  128. }
  129. public client_disconnected(id)
  130. {
  131. if (!is_user_bot(id))
  132. {
  133. InsertInfo(id);
  134. }
  135. }
  136.  
  137. public plugin_init()
  138. {
  139. register_plugin("Admin Commands", AMXX_VERSION_STR, "AMXX Dev Team")
  140.  
  141. register_dictionary("admincmd.txt")
  142. register_dictionary("common.txt")
  143. register_dictionary("adminhelp.txt")
  144.  
  145. register_concmd("amx_kick", "cmdKick", ADMIN_KICK, "<name or #userid> [reason]")
  146. register_concmd("amx_ban", "cmdBan", ADMIN_BAN|ADMIN_BAN_TEMP, "<name or #userid> <minutes> [reason]")
  147. register_concmd("amx_banip", "cmdBanIP", ADMIN_BAN|ADMIN_BAN_TEMP, "<name or #userid> <minutes> [reason]")
  148. register_concmd("amx_addban", "cmdAddBan", ADMIN_BAN, "<^"authid^" or ip> <minutes> [reason]")
  149. register_concmd("amx_unban", "cmdUnban", ADMIN_BAN|ADMIN_BAN_TEMP, "<^"authid^" or ip>")
  150. register_concmd("amx_slay", "cmdSlay", ADMIN_SLAY, "<name or #userid>")
  151. register_concmd("amx_slap", "cmdSlap", ADMIN_SLAY, "<name or #userid> [power]")
  152. register_concmd("amx_leave", "cmdLeave", ADMIN_KICK, "<tag> [tag] [tag] [tag]")
  153. register_concmd("amx_pause", "cmdPause", ADMIN_CVAR, "- pause or unpause the game")
  154. register_concmd("amx_who", "cmdWho", ADMIN_ADMIN, "- displays who is on server")
  155. register_concmd("amx_cvar", "cmdCvar", ADMIN_CVAR, "<cvar> [value]")
  156. register_concmd("amx_xvar_float", "cmdXvar", ADMIN_CVAR, "<xvar> [value]")
  157. register_concmd("amx_xvar_int", "cmdXvar", ADMIN_CVAR, "<xvar> [value]")
  158. register_concmd("amx_plugins", "cmdPlugins", ADMIN_ADMIN)
  159. register_concmd("amx_modules", "cmdModules", ADMIN_ADMIN)
  160. register_concmd("amx_map", "cmdMap", ADMIN_MAP, "<mapname>")
  161. register_concmd("amx_extendmap", "cmdExtendMap", ADMIN_MAP, "<number of minutes> - extend map")
  162. register_concmd("amx_cfg", "cmdCfg", ADMIN_CFG, "<filename>")
  163. register_concmd("amx_nick", "cmdNick", ADMIN_SLAY, "<name or #userid> <new nick>")
  164. register_concmd("amx_last", "cmdLast", ADMIN_BAN, "- list the last few disconnected clients info");
  165. register_clcmd("amx_rcon", "cmdRcon", ADMIN_RCON, "<command line>")
  166. register_clcmd("amx_showrcon", "cmdShowRcon", ADMIN_RCON, "<command line>")
  167. register_clcmd("pauseAck", "cmdLBack")
  168.  
  169. rcon_password=get_cvar_pointer("rcon_password");
  170. pausable=get_cvar_pointer("pausable");
  171. timelimit=get_cvar_pointer( "mp_timelimit" );
  172. p_amx_tempban_maxtime = register_cvar("amx_tempban_maxtime", "4320", FCVAR_PROTECTED);
  173.  
  174. g_tempBans = TrieCreate();
  175.  
  176. new flags = get_pcvar_flags(rcon_password);
  177.  
  178. if (!(flags & FCVAR_PROTECTED))
  179. {
  180. set_pcvar_flags(rcon_password, flags | FCVAR_PROTECTED);
  181. }
  182.  
  183. CC_SetPrefix("&x01[&x01BetterPlay&x01]")
  184.  
  185. }
  186.  
  187. public cmdKick(id, level, cid)
  188. {
  189. if (!cmd_access(id, level, cid, 2))
  190. return PLUGIN_HANDLED
  191.  
  192. new arg[32]
  193. read_argv(1, arg, charsmax(arg))
  194. new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF)
  195.  
  196. if (!player)
  197. return PLUGIN_HANDLED
  198.  
  199. new authid[32], authid2[32], name2[MAX_NAME_LENGTH], name[MAX_NAME_LENGTH], userid2, reason[32]
  200.  
  201. get_user_authid(id, authid, charsmax(authid))
  202. get_user_authid(player, authid2, charsmax(authid2))
  203. get_user_name(player, name2, charsmax(name2))
  204. get_user_name(id, name, charsmax(name))
  205. userid2 = get_user_userid(player)
  206. read_argv(2, reason, charsmax(reason))
  207. remove_quotes(reason)
  208.  
  209. log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^" (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, reason)
  210.  
  211. show_activity_key("ADMIN_KICK_1", "ADMIN_KICK_2", name, name2);
  212.  
  213. if (is_user_bot(player))
  214. server_cmd("kick #%d", userid2)
  215. else
  216. {
  217. if (reason[0])
  218. server_cmd("kick #%d ^"%s^"", userid2, reason)
  219. else
  220. server_cmd("kick #%d", userid2)
  221. }
  222.  
  223. console_print(id, "[AMXX] Client ^"%s^" kicked", name2)
  224.  
  225. return PLUGIN_HANDLED
  226. }
  227.  
  228. /**
  229. * ';' and '^n' are command delimiters. If a command arg contains these 2
  230. * it is not safe to be passed to server_cmd() as it may be trying to execute
  231. * a command.
  232. */
  233. isCommandArgSafe(const arg[])
  234. {
  235. return contain(arg, ";") == -1 && contain(arg, "^n") == -1;
  236. }
  237.  
  238. public cmdUnban(id, level, cid)
  239. {
  240. if (!cmd_access(id, level, cid, 2))
  241. return PLUGIN_HANDLED
  242.  
  243. new arg[32], authid[32], name[MAX_NAME_LENGTH]
  244.  
  245. read_argv(1, arg, charsmax(arg))
  246.  
  247. get_user_authid(id, authid, charsmax(authid))
  248.  
  249. if( !(get_user_flags(id) & ( ADMIN_BAN | ADMIN_RCON )) )
  250. {
  251. new storedAdminAuth[32]
  252. if( !TrieGetString(g_tempBans, arg, storedAdminAuth, charsmax(storedAdminAuth)) || !equal(storedAdminAuth, authid) )
  253. {
  254. console_print(id, "%L", id, "ADMIN_MUST_TEMPUNBAN");
  255. return PLUGIN_HANDLED;
  256. }
  257. }
  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. if(!isCommandArgSafe(arg))
  265. {
  266. console_print(id, "%l", "CL_NOT_FOUND");
  267. return PLUGIN_HANDLED;
  268. }
  269.  
  270. server_cmd("removeid %s;writeid", arg)
  271. console_print(id, "[AMXX] %L", id, "AUTHID_REMOVED", arg)
  272. }
  273.  
  274. get_user_name(id, name, charsmax(name))
  275.  
  276. show_activity_key("ADMIN_UNBAN_1", "ADMIN_UNBAN_2", name, arg);
  277.  
  278. log_amx("Cmd: ^"%s<%d><%s><>^" unban ^"%s^"", name, get_user_userid(id), authid, arg)
  279.  
  280. return PLUGIN_HANDLED
  281. }
  282.  
  283. /* amx_addban is a special command now.
  284. * If a user with rcon uses it, it bans the user. No questions asked.
  285. * If a user without rcon but with ADMIN_BAN uses it, it will scan the old
  286. * connection queue, and if it finds the info for a player in it, it will
  287. * check their old access. If they have immunity, it will not ban.
  288. * If they do not have immunity, it will ban. If the user is not found,
  289. * it will refuse to ban the target.
  290. */
  291.  
  292. public cmdAddBan(id, level, cid)
  293. {
  294. if (!cmd_access(id, level, cid, 3, true)) // check for ADMIN_BAN access
  295. {
  296. if (get_user_flags(id) & level) // Getting here means they didn't input enough args
  297. {
  298. return PLUGIN_HANDLED;
  299. }
  300. if (!cmd_access(id, ADMIN_RCON, cid, 3)) // If somehow they have ADMIN_RCON without ADMIN_BAN, continue
  301. {
  302. return PLUGIN_HANDLED;
  303. }
  304. }
  305.  
  306. new arg[32], authid[32], name[MAX_NAME_LENGTH], minutes[32], reason[32]
  307.  
  308. read_argv(1, arg, charsmax(arg))
  309. read_argv(2, minutes, charsmax(minutes))
  310. read_argv(3, reason, charsmax(reason))
  311.  
  312. trim(arg);
  313.  
  314. if (!(get_user_flags(id) & ADMIN_RCON))
  315. {
  316. new bool:canban = false;
  317. new bool:isip = false;
  318. // Limited access to this command
  319. if (equali(arg, "STEAM_ID_PENDING") ||
  320. equali(arg, "STEAM_ID_LAN") ||
  321. equali(arg, "HLTV") ||
  322. equali(arg, "4294967295") ||
  323. equali(arg, "VALVE_ID_LAN") ||
  324. equali(arg, "VALVE_ID_PENDING"))
  325. {
  326. // Hopefully we never get here, so ML shouldn't be needed
  327. console_print(id, "Cannot ban %s", arg);
  328. return PLUGIN_HANDLED;
  329. }
  330.  
  331. if (contain(arg, ".") != -1)
  332. {
  333. isip = true;
  334. }
  335.  
  336. // Scan the disconnection queue
  337. if (isip)
  338. {
  339. new IP[32];
  340. new Name[MAX_NAME_LENGTH];
  341. new dummy[1];
  342. new Access;
  343. for (new i = 0; i < g_Size; i++)
  344. {
  345. GetInfo(i, Name, charsmax(Name), dummy, 0, IP, charsmax(IP), Access);
  346.  
  347. if (equal(IP, arg))
  348. {
  349. if (Access & ADMIN_IMMUNITY)
  350. {
  351. console_print(id, "[AMXX] %s : %L", IP, id, "CLIENT_IMM", Name);
  352.  
  353. return PLUGIN_HANDLED;
  354. }
  355. // User did not have immunity
  356. canban = true;
  357. }
  358. }
  359. }
  360. else
  361. {
  362. new Auth[32];
  363. new Name[MAX_NAME_LENGTH];
  364. new dummy[1];
  365. new Access;
  366. for (new i = 0; i < g_Size; i++)
  367. {
  368. GetInfo(i, Name, charsmax(Name), Auth, charsmax(Auth), dummy, 0, Access);
  369.  
  370. if (equal(Auth, arg))
  371. {
  372. if (Access & ADMIN_IMMUNITY)
  373. {
  374. console_print(id, "[AMXX] %s : %L", Auth, id, "CLIENT_IMM", Name);
  375.  
  376. return PLUGIN_HANDLED;
  377. }
  378. // User did not have immunity
  379. canban = true;
  380. }
  381. }
  382. }
  383.  
  384. if (!canban)
  385. {
  386. console_print(id, "[AMXX] You may only ban recently disconnected clients. Use ^"amx_last^" to view.");
  387.  
  388. return PLUGIN_HANDLED;
  389. }
  390.  
  391. }
  392.  
  393. // User has access to ban their target
  394. if (contain(arg, ".") != -1)
  395. {
  396. server_cmd("addip ^"%s^" ^"%s^";wait;writeip", minutes, arg)
  397. console_print(id, "[AMXX] Ip ^"%s^" added to ban list", arg)
  398. } else {
  399. if(!isCommandArgSafe(arg))
  400. {
  401. console_print(id, "%l", "CL_NOT_FOUND");
  402. return PLUGIN_HANDLED;
  403. }
  404.  
  405. server_cmd("banid ^"%s^" %s;wait;writeid", minutes, arg)
  406. console_print(id, "[AMXX] Authid ^"%s^" added to ban list", arg)
  407. }
  408.  
  409. get_user_name(id, name, charsmax(name))
  410.  
  411. show_activity_key("ADMIN_ADDBAN_1", "ADMIN_ADDBAN_2", name, arg);
  412.  
  413. get_user_authid(id, authid, charsmax(authid))
  414. TrieSetString(g_tempBans, arg, authid)
  415. log_amx("Cmd: ^"%s<%d><%s><>^" ban ^"%s^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, arg, minutes, reason)
  416.  
  417. return PLUGIN_HANDLED
  418. }
  419.  
  420. public cmdBan(id, level, cid)
  421. {
  422. if (!cmd_access(id, level, cid, 3))
  423. return PLUGIN_HANDLED
  424.  
  425. new target[32], minutes[8], reason[64]
  426.  
  427. read_argv(1, target, charsmax(target))
  428. read_argv(2, minutes, charsmax(minutes))
  429. read_argv(3, reason, charsmax(reason))
  430.  
  431. new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)
  432.  
  433. if (!player)
  434. return PLUGIN_HANDLED
  435.  
  436. new nNum = str_to_num(minutes)
  437. new const tempBanMaxTime = get_pcvar_num(p_amx_tempban_maxtime);
  438. if( nNum < 0 ) // since negative values result in permanent bans
  439. {
  440. nNum = 0;
  441. minutes = "0";
  442. }
  443. if( !(get_user_flags(id) & ( ADMIN_BAN | ADMIN_RCON )) && (nNum <= 0 || nNum > tempBanMaxTime) )
  444. {
  445. console_print(id, "%L", id, "ADMIN_MUST_TEMPBAN", tempBanMaxTime);
  446. return PLUGIN_HANDLED
  447. }
  448.  
  449. new authid[32], name2[MAX_NAME_LENGTH], authid2[32], name[MAX_NAME_LENGTH]
  450. new userid2 = get_user_userid(player)
  451.  
  452. get_user_authid(player, authid2, charsmax(authid2))
  453. get_user_authid(id, authid, charsmax(authid))
  454. get_user_name(player, name2, charsmax(name2))
  455. get_user_name(id, name, charsmax(name))
  456.  
  457. 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)
  458.  
  459. TrieSetString(g_tempBans, authid2, authid); // store all bans in case a permanent ban would override a temporary one.
  460.  
  461. new temp[64], banned[16]
  462. if (nNum)
  463. formatex(temp, charsmax(temp), "%L", player, "FOR_MIN", minutes)
  464. else
  465. formatex(temp, charsmax(temp), "%L", player, "PERM")
  466.  
  467. formatex(banned, charsmax(banned), "%L", player, "BANNED")
  468.  
  469. if (reason[0])
  470. server_cmd("kick #%d ^"%s (%s %s)^";wait;banid %s %s;wait;writeid", userid2, reason, banned, temp, minutes, authid2)
  471. else
  472. server_cmd("kick #%d ^"%s %s^";wait;banid %s %s;wait;writeid", userid2, banned, temp, minutes, authid2)
  473.  
  474.  
  475. // Display the message to all clients
  476.  
  477. new msg[256];
  478. new len;
  479. new players[MAX_PLAYERS], pnum, plr
  480. get_players(players, pnum, "ch")
  481. for (new i; i<pnum; i++)
  482. {
  483. plr = players[i]
  484.  
  485. len = formatex(msg, charsmax(msg), "%L", plr, "BAN");
  486. len += formatex(msg[len], charsmax(msg) - len, " %s ", name2);
  487. if (nNum)
  488. {
  489. len += formatex(msg[len], charsmax(msg) - len, "%L", plr, "FOR_MIN", minutes);
  490. }
  491. else
  492. {
  493. len += formatex(msg[len], charsmax(msg) - len, "%L", plr, "PERM");
  494. }
  495. if (strlen(reason) > 0)
  496. {
  497. formatex(msg[len], charsmax(msg) - len, " (%L: %s)", plr, "REASON", reason);
  498. }
  499. show_activity_id(plr, id, name, msg);
  500. }
  501.  
  502. console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)
  503.  
  504. return PLUGIN_HANDLED
  505. }
  506.  
  507. public cmdBanIP(id, level, cid)
  508. {
  509. if (!cmd_access(id, level, cid, 3))
  510. return PLUGIN_HANDLED
  511.  
  512. new target[32], minutes[8], reason[64]
  513.  
  514. read_argv(1, target, charsmax(target))
  515. read_argv(2, minutes, charsmax(minutes))
  516. read_argv(3, reason, charsmax(reason))
  517.  
  518. new player = cmd_target(id, target, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)
  519.  
  520. if (!player)
  521. return PLUGIN_HANDLED
  522.  
  523. new nNum = str_to_num(minutes)
  524. new const tempBanMaxTime = get_pcvar_num(p_amx_tempban_maxtime);
  525. if( nNum < 0 ) // since negative values result in permanent bans
  526. {
  527. nNum = 0;
  528. minutes = "0";
  529. }
  530. if( !(get_user_flags(id) & ( ADMIN_BAN | ADMIN_RCON )) && (nNum <= 0 || nNum > tempBanMaxTime) )
  531. {
  532. console_print(id, "%L", id, "ADMIN_MUST_TEMPBAN", tempBanMaxTime);
  533. return PLUGIN_HANDLED
  534. }
  535.  
  536. new authid[32], name2[MAX_NAME_LENGTH], authid2[32], name[MAX_NAME_LENGTH]
  537. new userid2 = get_user_userid(player)
  538.  
  539. get_user_authid(player, authid2, charsmax(authid2))
  540. get_user_authid(id, authid, charsmax(authid))
  541. get_user_name(player, name2, charsmax(name2))
  542. get_user_name(id, name, charsmax(name))
  543.  
  544. 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)
  545.  
  546. TrieSetString(g_tempBans, authid2, authid);
  547.  
  548. new temp[64], banned[16]
  549. if (nNum)
  550. formatex(temp, charsmax(temp), "%L", player, "FOR_MIN", minutes)
  551. else
  552. formatex(temp, charsmax(temp), "%L", player, "PERM")
  553. format(banned, 15, "%L", player, "BANNED")
  554.  
  555. new address[32]
  556. get_user_ip(player, address, charsmax(address), 1)
  557.  
  558. if (reason[0])
  559. server_cmd("kick #%d ^"%s (%s %s)^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, reason, banned, temp, minutes, address)
  560. else
  561. server_cmd("kick #%d ^"%s %s^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, banned, temp, minutes, address)
  562.  
  563. // Display the message to all clients
  564.  
  565. new msg[256];
  566. new len;
  567. new players[MAX_PLAYERS], pnum, plr
  568. get_players(players, pnum, "ch")
  569. for (new i; i<pnum; i++)
  570. {
  571. plr = players[i]
  572.  
  573. len = formatex(msg, charsmax(msg), "%L", plr, "BAN");
  574. len += formatex(msg[len], charsmax(msg) - len, " %s ", name2);
  575. if (nNum)
  576. {
  577. formatex(msg[len], charsmax(msg) - len, "%L", plr, "FOR_MIN", minutes);
  578. }
  579. else
  580. {
  581. formatex(msg[len], charsmax(msg) - len, "%L", plr, "PERM");
  582. }
  583. if (strlen(reason) > 0)
  584. {
  585. formatex(msg[len], charsmax(msg) - len, " (%L: %s)", plr, "REASON", reason);
  586. }
  587. show_activity_id(plr, id, name, msg);
  588. }
  589.  
  590. console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)
  591.  
  592. return PLUGIN_HANDLED
  593. }
  594.  
  595. public cmdSlay(id, level, cid)
  596. {
  597. if (!cmd_access(id, level, cid, 2))
  598. return PLUGIN_HANDLED
  599.  
  600. new arg[32]
  601.  
  602. read_argv(1, arg, charsmax(arg))
  603.  
  604. new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE)
  605.  
  606. if (!player)
  607. return PLUGIN_HANDLED
  608.  
  609. user_kill(player)
  610.  
  611. new authid[32], name2[MAX_NAME_LENGTH], authid2[32], name[MAX_NAME_LENGTH]
  612.  
  613. get_user_authid(id, authid, charsmax(authid))
  614. get_user_name(id, name, charsmax(name))
  615. get_user_authid(player, authid2, charsmax(authid2))
  616. get_user_name(player, name2, charsmax(name2))
  617.  
  618. log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
  619.  
  620. show_activity_key("ADMIN_SLAY_1", "ADMIN_SLAY_2", name, name2);
  621.  
  622. console_print(id, "[AMXX] %L", id, "CLIENT_SLAYED", name2)
  623.  
  624. return PLUGIN_HANDLED
  625. }
  626.  
  627. public cmdSlap(id, level, cid)
  628. {
  629. if (!cmd_access(id, level, cid, 2))
  630. return PLUGIN_HANDLED
  631.  
  632. new arg[32]
  633.  
  634. read_argv(1, arg, charsmax(arg))
  635. new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE)
  636.  
  637. if (!player)
  638. return PLUGIN_HANDLED
  639.  
  640. new spower[32], authid[32], name2[MAX_NAME_LENGTH], authid2[32], name[MAX_NAME_LENGTH]
  641.  
  642. read_argv(2, spower, charsmax(spower))
  643.  
  644. new damage = clamp( str_to_num(spower), 0)
  645.  
  646. user_slap(player, damage)
  647.  
  648. get_user_authid(id, authid, charsmax(authid))
  649. get_user_name(id, name, charsmax(name))
  650. get_user_authid(player, authid2, charsmax(authid2))
  651. get_user_name(player, name2, charsmax(name2))
  652.  
  653. 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)
  654.  
  655. show_activity_key("ADMIN_SLAP_1", "ADMIN_SLAP_2", name, name2, damage);
  656.  
  657. console_print(id, "[AMXX] %L", id, "CLIENT_SLAPED", name2, damage)
  658.  
  659. return PLUGIN_HANDLED
  660. }
  661.  
  662. public chMap(map[])
  663. {
  664. engine_changelevel(map);
  665. }
  666.  
  667. public cmdMap(id, level, cid)
  668. {
  669. if (!cmd_access(id, level, cid, 2))
  670. return PLUGIN_HANDLED
  671.  
  672. new arg[32]
  673. new arglen = read_argv(1, arg, charsmax(arg))
  674.  
  675. if (!is_map_valid(arg) || contain(arg, "..") != -1)
  676. {
  677. console_print(id, "[AMXX] %L", id, "MAP_NOT_FOUND")
  678. return PLUGIN_HANDLED
  679. }
  680.  
  681. new authid[32], name[MAX_NAME_LENGTH]
  682.  
  683. get_user_authid(id, authid, charsmax(authid))
  684. get_user_name(id, name, charsmax(name))
  685.  
  686. show_activity_key("ADMIN_MAP_1", "ADMIN_MAP_2", name, arg);
  687.  
  688. log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", name, get_user_userid(id), authid, arg)
  689.  
  690. new _modName[10]
  691. get_modname(_modName, charsmax(_modName))
  692.  
  693. if (!equal(_modName, "zp"))
  694. {
  695. message_begin(MSG_ALL, SVC_INTERMISSION)
  696. message_end()
  697. }
  698.  
  699. set_task(2.0, "chMap", 0, arg, arglen + 1)
  700.  
  701. return PLUGIN_HANDLED
  702. }
  703.  
  704. public cmdExtendMap(id, level, cid)
  705. {
  706. if(!cmd_access(id, level, cid, 2))
  707. return PLUGIN_HANDLED
  708.  
  709. new arg[32]
  710. read_argv(1, arg, charsmax(arg))
  711. new mns = str_to_num(arg)
  712.  
  713. if(mns <= 0)
  714. return PLUGIN_HANDLED
  715.  
  716. new mapname[32]
  717. get_mapname(mapname, charsmax(mapname))
  718. set_pcvar_num( timelimit , get_pcvar_num( timelimit ) + mns)
  719.  
  720. new authid[32], name[MAX_NAME_LENGTH]
  721.  
  722. get_user_authid(id, authid, charsmax(authid))
  723. get_user_name(id, name, charsmax(name))
  724.  
  725. show_activity_key("ADMIN_EXTEND_1", "ADMIN_EXTEND_2", name, mns)
  726.  
  727. log_amx("ExtendMap: ^"%s<%d><%s><>^" extended map ^"%s^" for %d minutes.", name, get_user_userid(id), authid, mapname, mns)
  728. console_print(id, "%L", id, "MAP_EXTENDED", mapname, mns)
  729.  
  730. return PLUGIN_HANDLED
  731. }
  732.  
  733. stock bool:onlyRcon(const name[])
  734. {
  735. new ptr=get_cvar_pointer(name);
  736. if (ptr && get_pcvar_flags(ptr) & FCVAR_PROTECTED)
  737. {
  738. return true;
  739. }
  740. return false;
  741. }
  742.  
  743. public cmdCvar(id, level, cid)
  744. {
  745. if (!cmd_access(id, level, cid, 2))
  746. return PLUGIN_HANDLED
  747.  
  748. new arg[32], arg2[64]
  749.  
  750. read_argv(1, arg, charsmax(arg))
  751. read_argv(2, arg2, charsmax(arg2))
  752.  
  753. new pointer;
  754.  
  755. if (equal(arg, "add") && (get_user_flags(id) & ADMIN_RCON))
  756. {
  757. if ((pointer=get_cvar_pointer(arg2))!=0)
  758. {
  759. new flags=get_pcvar_flags(pointer);
  760.  
  761. if (!(flags & FCVAR_PROTECTED))
  762. {
  763. set_pcvar_flags(pointer,flags | FCVAR_PROTECTED);
  764. }
  765. }
  766. return PLUGIN_HANDLED
  767. }
  768.  
  769. trim(arg);
  770.  
  771. if ((pointer=get_cvar_pointer(arg))==0)
  772. {
  773. console_print(id, "[AMXX] %L", id, "UNKNOWN_CVAR", arg)
  774. return PLUGIN_HANDLED
  775. }
  776.  
  777. if (onlyRcon(arg) && !(get_user_flags(id) & ADMIN_RCON))
  778. {
  779. // Exception for the new onlyRcon rules:
  780. // sv_password is allowed to be modified by ADMIN_PASSWORD
  781. if (!(equali(arg,"sv_password") && (get_user_flags(id) & ADMIN_PASSWORD)))
  782. {
  783. console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC")
  784. return PLUGIN_HANDLED
  785. }
  786. }
  787.  
  788. if (read_argc() < 3)
  789. {
  790. get_pcvar_string(pointer, arg2, charsmax(arg2))
  791. console_print(id, "[AMXX] %L", id, "CVAR_IS", arg, arg2)
  792. return PLUGIN_HANDLED
  793. }
  794.  
  795. if ((get_pcvar_flags(pointer) & FCVAR_SPONLY) && MaxClients != 1)
  796. {
  797. console_print(id, "[AMXX] %L", id, "CVAR_NO_ACC")
  798. return PLUGIN_HANDLED
  799. }
  800.  
  801. if (equali(arg, "servercfgfile") || equali(arg, "lservercfgfile") || equali(arg, "mapchangecfgfile"))
  802. {
  803. new pos = contain(arg2, ";")
  804. if (pos != -1)
  805. {
  806. arg2[pos] = '^0'
  807. }
  808. else if ((pos = contain(arg2, "^n")) != -1)
  809. {
  810. arg2[pos] = '^0'
  811. }
  812. }
  813.  
  814. new authid[32], name[MAX_NAME_LENGTH]
  815.  
  816. get_user_authid(id, authid, charsmax(authid))
  817. get_user_name(id, name, charsmax(name))
  818.  
  819. log_amx("Cmd: ^"%s<%d><%s><>^" set cvar (name ^"%s^") (value ^"%s^")", name, get_user_userid(id), authid, arg, arg2)
  820. set_pcvar_string(pointer, arg2)
  821.  
  822.  
  823. // Display the message to all clients
  824.  
  825. new cvar_val[64];
  826. new players[MAX_PLAYERS], pnum, plr
  827. get_players(players, pnum, "ch")
  828. for (new i; i<pnum; i++)
  829. {
  830. plr = players[i]
  831. if (get_pcvar_flags(pointer) & FCVAR_PROTECTED || equali(arg, "rcon_password"))
  832. {
  833. formatex(cvar_val, charsmax(cvar_val), "*** %L ***", plr, "PROTECTED");
  834. }
  835. else
  836. {
  837. copy(cvar_val, charsmax(cvar_val), arg2);
  838. }
  839. show_activity_id(plr, id, name, "%L", plr, "SET_CVAR_TO", "", arg, cvar_val);
  840. }
  841.  
  842. console_print(id, "[AMXX] %L", id, "CVAR_CHANGED", arg, arg2)
  843.  
  844. return PLUGIN_HANDLED
  845. }
  846.  
  847. public cmdXvar(id, level, cid)
  848. {
  849. if( !cmd_access(id, level, cid, 2) )
  850. {
  851. return PLUGIN_HANDLED;
  852. }
  853.  
  854. new cmd[15], arg1[32], arg2[32];
  855.  
  856. read_argv(0, cmd, charsmax(cmd));
  857. read_argv(1, arg1, charsmax(arg1));
  858. trim(arg1);
  859. if( read_argc() > 2 )
  860. {
  861. read_argv(2, arg2, charsmax(arg2));
  862. trim(arg2);
  863.  
  864. if( equali(arg1, "add") )
  865. {
  866. if( get_user_flags(id) & ADMIN_RCON && xvar_exists(arg2) )
  867. {
  868. if( !g_tXvarsFlags )
  869. {
  870. g_tXvarsFlags = TrieCreate();
  871. }
  872. TrieSetCell(g_tXvarsFlags, arg2, 1);
  873. }
  874. return PLUGIN_HANDLED;
  875. }
  876. }
  877.  
  878. new bFloat = equali(cmd, "amx_xvar_float");
  879.  
  880. new xvar = get_xvar_id( arg1 );
  881.  
  882. if( xvar == -1 )
  883. {
  884. console_print(id, "[AMXX] %L", id, "UNKNOWN_XVAR", arg1)
  885. return PLUGIN_HANDLED
  886. }
  887.  
  888. new any:value;
  889.  
  890. if( !arg2[0] ) // get value
  891. {
  892. value = get_xvar_num(xvar);
  893. if( bFloat )
  894. {
  895. float_to_str(value, arg2, charsmax(arg2));
  896. }
  897. else
  898. {
  899. num_to_str(value, arg2, charsmax(arg2));
  900. }
  901. console_print(id, "[AMXX] %L", id, "XVAR_IS", arg1, arg2);
  902. return PLUGIN_HANDLED;
  903. }
  904.  
  905. // set value
  906. if( g_tXvarsFlags && TrieKeyExists(g_tXvarsFlags, arg1) && ~get_user_flags(id) & ADMIN_RCON )
  907. {
  908. console_print(id, "[AMXX] %L", id, "XVAR_NO_ACC");
  909. return PLUGIN_HANDLED;
  910. }
  911.  
  912. new endPos;
  913. if( bFloat )
  914. {
  915. value = strtof(arg2, endPos);
  916. if( !endPos )
  917. {
  918. return PLUGIN_HANDLED;
  919. }
  920. }
  921. else
  922. {
  923. value = strtol(arg2, endPos);
  924. if( !endPos )
  925. {
  926. return PLUGIN_HANDLED;
  927. }
  928. }
  929.  
  930. set_xvar_num(xvar, value);
  931.  
  932. // convert back value to string so admin can know value has been set correctly
  933. if( bFloat )
  934. {
  935. float_to_str(value, arg2, charsmax(arg2));
  936. }
  937. else
  938. {
  939. num_to_str(value, arg2, charsmax(arg2));
  940. }
  941.  
  942. new authid[32], name[MAX_NAME_LENGTH];
  943.  
  944. get_user_authid(id, authid, charsmax(authid));
  945. get_user_name(id, name, charsmax(name));
  946.  
  947. log_amx("Cmd: ^"%s<%d><%s><>^" set xvar (name ^"%s^") (value ^"%s^")", name, get_user_userid(id), authid, arg1, arg2);
  948.  
  949. // Display the message to all clients
  950. new players[MAX_PLAYERS], pnum, plr;
  951. get_players(players, pnum, "ch");
  952. for (new i; i<pnum; i++)
  953. {
  954. plr = players[i];
  955. show_activity_id(plr, id, name, "%L", plr, "SET_XVAR_TO", "", arg1, arg2);
  956. }
  957.  
  958. console_print(id, "[AMXX] %L", id, "XVAR_CHANGED", arg1, arg2);
  959.  
  960. return PLUGIN_HANDLED;
  961. }
  962.  
  963. public cmdPlugins(id, level, cid)
  964. {
  965. if (!cmd_access(id, level, cid, 1))
  966. return PLUGIN_HANDLED
  967.  
  968. if (id==0) // If server executes redirect this to "amxx plugins" for more in depth output
  969. {
  970. server_cmd("amxx plugins");
  971. server_exec();
  972. return PLUGIN_HANDLED;
  973. }
  974.  
  975. new name[MAX_NAME_LENGTH], version[32], author[32], filename[32], status[32]
  976. new lName[32], lVersion[32], lAuthor[32], lFile[32], lStatus[32]
  977.  
  978. format(lName, charsmax(lName), "%L", id, "NAME")
  979. format(lVersion, charsmax(lVersion), "%L", id, "VERSION")
  980. format(lAuthor, charsmax(lAuthor), "%L", id, "AUTHOR")
  981. format(lFile, charsmax(lFile), "%L", id, "FILE")
  982. format(lStatus, charsmax(lStatus), "%L", id, "STATUS")
  983.  
  984. new StartPLID=0;
  985. new EndPLID;
  986.  
  987. new Temp[96]
  988.  
  989. new num = get_pluginsnum()
  990.  
  991. if (read_argc() > 1)
  992. {
  993. read_argv(1,Temp,charsmax(Temp));
  994. StartPLID=str_to_num(Temp)-1; // zero-based
  995. }
  996.  
  997. EndPLID=min(StartPLID + 10, num);
  998.  
  999. new running = 0
  1000.  
  1001. console_print(id, "----- %L -----", id, "LOADED_PLUGINS")
  1002. console_print(id, "%-18.17s %-11.10s %-17.16s %-16.15s %-9.8s", lName, lVersion, lAuthor, lFile, lStatus)
  1003.  
  1004. new i=StartPLID;
  1005. while (i <EndPLID)
  1006. {
  1007. get_plugin(i++, filename, charsmax(filename), name, charsmax(name), version, charsmax(version), author, charsmax(author), status, charsmax(status))
  1008. console_print(id, "%-18.17s %-11.10s %-17.16s %-16.15s %-9.8s", name, version, author, filename, status)
  1009.  
  1010. if (status[0]=='d' || status[0]=='r') // "debug" or "running"
  1011. running++
  1012. }
  1013. console_print(id, "%L", id, "PLUGINS_RUN", EndPLID-StartPLID, running)
  1014. console_print(id, "----- %L -----",id,"HELP_ENTRIES",StartPLID + 1,EndPLID,num);
  1015.  
  1016. if (EndPLID < num)
  1017. {
  1018. formatex(Temp,charsmax(Temp),"----- %L -----",id,"HELP_USE_MORE", "amx_help", EndPLID + 1);
  1019. replace_all(Temp,charsmax(Temp),"amx_help","amx_plugins");
  1020. console_print(id,"%s",Temp);
  1021. }
  1022. else
  1023. {
  1024. formatex(Temp,charsmax(Temp),"----- %L -----",id,"HELP_USE_BEGIN", "amx_help");
  1025. replace_all(Temp,charsmax(Temp),"amx_help","amx_plugins");
  1026. console_print(id,"%s",Temp);
  1027. }
  1028.  
  1029. return PLUGIN_HANDLED
  1030. }
  1031.  
  1032. public cmdModules(id, level, cid)
  1033. {
  1034. if (!cmd_access(id, level, cid, 1))
  1035. return PLUGIN_HANDLED
  1036.  
  1037. new name[32], version[32], author[32], status, sStatus[16]
  1038. new lName[32], lVersion[32], lAuthor[32], lStatus[32];
  1039.  
  1040. format(lName, charsmax(lName), "%L", id, "NAME")
  1041. format(lVersion, charsmax(lVersion), "%L", id, "VERSION")
  1042. format(lAuthor, charsmax(lAuthor), "%L", id, "AUTHOR")
  1043. format(lStatus, charsmax(lStatus), "%L", id, "STATUS")
  1044.  
  1045. new num = get_modulesnum()
  1046.  
  1047. console_print(id, "%L:", id, "LOADED_MODULES")
  1048. console_print(id, "%-23.22s %-11.10s %-20.19s %-11.10s", lName, lVersion, lAuthor, lStatus)
  1049.  
  1050. for (new i = 0; i < num; i++)
  1051. {
  1052. get_module(i, name, charsmax(name), author, charsmax(author), version, charsmax(version), status)
  1053.  
  1054. switch (status)
  1055. {
  1056. case module_loaded: copy(sStatus, charsmax(sStatus), "running")
  1057. default:
  1058. {
  1059. copy(sStatus, charsmax(sStatus), "bad load");
  1060. copy(name, charsmax(name), "unknown");
  1061. copy(author, charsmax(author), "unknown");
  1062. copy(version, charsmax(version), "unknown");
  1063. }
  1064. }
  1065.  
  1066. console_print(id, "%-23.22s %-11.10s %-20.19s %-11.10s", name, version, author, sStatus)
  1067. }
  1068. console_print(id, "%L", id, "NUM_MODULES", num)
  1069.  
  1070. return PLUGIN_HANDLED
  1071. }
  1072.  
  1073. public cmdCfg(id, level, cid)
  1074. {
  1075. if (!cmd_access(id, level, cid, 2))
  1076. return PLUGIN_HANDLED
  1077.  
  1078. new arg[128]
  1079. read_argv(1, arg, charsmax(arg))
  1080.  
  1081. if (!file_exists(arg))
  1082. {
  1083. console_print(id, "[AMXX] %L", id, "FILE_NOT_FOUND", arg)
  1084. return PLUGIN_HANDLED
  1085. }
  1086.  
  1087. new authid[32], name[MAX_NAME_LENGTH]
  1088.  
  1089. get_user_authid(id, authid, charsmax(authid))
  1090. get_user_name(id, name, charsmax(name))
  1091.  
  1092. log_amx("Cmd: ^"%s<%d><%s><>^" execute cfg (file ^"%s^")", name, get_user_userid(id), authid, arg)
  1093.  
  1094. console_print(id, "[AMXX] Executing file ^"%s^"", arg)
  1095. server_cmd("exec ^"%s^"", arg)
  1096.  
  1097. show_activity_key("ADMIN_CONF_1", "ADMIN_CONF_2", name, arg);
  1098.  
  1099. return PLUGIN_HANDLED
  1100. }
  1101.  
  1102. public cmdLBack()
  1103. {
  1104. if (!g_PauseAllowed)
  1105. return PLUGIN_CONTINUE
  1106.  
  1107. new paused[25]
  1108.  
  1109. format(paused, 24, "%L", g_pauseCon, g_Paused ? "UNPAUSED" : "PAUSED")
  1110. set_pcvar_float(pausable, g_pausAble)
  1111. console_print(g_pauseCon, "[AMXX] Server %s", paused)
  1112. g_PauseAllowed = false
  1113.  
  1114. if (g_Paused)
  1115. g_Paused = false
  1116. else
  1117. g_Paused = true
  1118.  
  1119. return PLUGIN_HANDLED
  1120. }
  1121.  
  1122. public cmdPause(id, level, cid)
  1123. {
  1124. if (!cmd_access(id, level, cid, 1))
  1125. return PLUGIN_HANDLED
  1126.  
  1127. new authid[32], name[MAX_NAME_LENGTH], slayer = id
  1128.  
  1129. get_user_authid(id, authid, charsmax(authid))
  1130. get_user_name(id, name, charsmax(name))
  1131. if (pausable!=0)
  1132. {
  1133. g_pausAble = get_pcvar_float(pausable)
  1134. }
  1135.  
  1136. if (!slayer)
  1137. slayer = find_player("h")
  1138.  
  1139. if (!slayer)
  1140. {
  1141. console_print(id, "[AMXX] %L", id, "UNABLE_PAUSE")
  1142. return PLUGIN_HANDLED
  1143. }
  1144.  
  1145. set_pcvar_float(pausable, 1.0)
  1146. g_PauseAllowed = true
  1147. client_cmd(slayer, "pause;pauseAck")
  1148.  
  1149. log_amx("Cmd: ^"%s<%d><%s><>^" %s server", name, get_user_userid(id), authid, g_Paused ? "unpause" : "pause")
  1150.  
  1151. console_print(id, "[AMXX] %L", id, g_Paused ? "UNPAUSING" : "PAUSING")
  1152.  
  1153. // Display the message to all clients
  1154.  
  1155. new players[MAX_PLAYERS], pnum
  1156. get_players(players, pnum, "ch")
  1157. for (new i; i<pnum; i++)
  1158. {
  1159. show_activity_id(players[i], id, name, "%L server", i, g_Paused ? "UNPAUSE" : "PAUSE");
  1160. }
  1161.  
  1162. g_pauseCon = id
  1163.  
  1164. return PLUGIN_HANDLED
  1165. }
  1166.  
  1167. public cmdShowRcon(id, level, cid)
  1168. {
  1169. if (!cmd_access(id, level, cid, 2))
  1170. return PLUGIN_HANDLED
  1171.  
  1172. new password[64]
  1173.  
  1174. get_pcvar_string(rcon_password, password, charsmax(password))
  1175.  
  1176. if (!password[0])
  1177. {
  1178. cmdRcon(id, level, cid)
  1179. }
  1180. else
  1181. {
  1182. new args[128]
  1183.  
  1184. read_args(args, charsmax(args))
  1185. client_cmd(id, "rcon_password %s", password)
  1186. client_cmd(id, "rcon %s", args)
  1187. }
  1188.  
  1189. return PLUGIN_HANDLED
  1190. }
  1191.  
  1192. public cmdRcon(id, level, cid)
  1193. {
  1194. if (!cmd_access(id, level, cid, 2))
  1195. return PLUGIN_HANDLED
  1196.  
  1197. new arg[128], authid[32], name[MAX_NAME_LENGTH]
  1198.  
  1199. read_args(arg, charsmax(arg))
  1200. get_user_authid(id, authid, charsmax(authid))
  1201. get_user_name(id, name, charsmax(name))
  1202.  
  1203. log_amx("Cmd: ^"%s<%d><%s><>^" server console (cmdline ^"%s^")", name, get_user_userid(id), authid, arg)
  1204.  
  1205. console_print(id, "[AMXX] %L", id, "COM_SENT_SERVER", arg)
  1206. server_cmd("%s", arg)
  1207.  
  1208. return PLUGIN_HANDLED
  1209. }
  1210.  
  1211. public cmdWho(id, level, cid)
  1212. {
  1213. if (!cmd_access(id, level, cid, 1))
  1214. return PLUGIN_HANDLED
  1215.  
  1216. new players[MAX_PLAYERS], inum, cl_on_server[64], authid[32], name[MAX_NAME_LENGTH], flags, sflags[32], plr
  1217. new lImm[16], lRes[16], lAccess[16], lYes[16], lNo[16]
  1218.  
  1219. formatex(lImm, charsmax(lImm), "%L", id, "IMMU")
  1220. formatex(lRes, charsmax(lRes), "%L", id, "RESERV")
  1221. formatex(lAccess, charsmax(lAccess), "%L", id, "ACCESS")
  1222. formatex(lYes, charsmax(lYes), "%L", id, "YES")
  1223. formatex(lNo, charsmax(lNo), "%L", id, "NO")
  1224.  
  1225. get_players(players, inum)
  1226. format(cl_on_server, charsmax(cl_on_server), "%L", id, "CLIENTS_ON_SERVER")
  1227. console_print(id, "^n%s:^n # %-16.15s %-20s %-8s %-4.3s %-4.3s %s", cl_on_server, "nick", "authid", "userid", lImm, lRes, lAccess)
  1228.  
  1229. for (new a = 0; a < inum; ++a)
  1230. {
  1231. plr = players[a]
  1232. get_user_authid(plr, authid, charsmax(authid))
  1233. get_user_name(plr, name, charsmax(name))
  1234. flags = get_user_flags(plr)
  1235. get_flags(flags, sflags, charsmax(sflags))
  1236. console_print(id, "%2d %-16.15s %-20s %-8d %-6.5s %-6.5s %s", plr, name, authid,
  1237. get_user_userid(plr), (flags&ADMIN_IMMUNITY) ? lYes : lNo, (flags&ADMIN_RESERVATION) ? lYes : lNo, sflags)
  1238. }
  1239.  
  1240. console_print(id, "%L", id, "TOTAL_NUM", inum)
  1241. get_user_authid(id, authid, charsmax(authid))
  1242. get_user_name(id, name, charsmax(name))
  1243. log_amx("Cmd: ^"%s<%d><%s><>^" ask for players list", name, get_user_userid(id), authid)
  1244.  
  1245. return PLUGIN_HANDLED
  1246. }
  1247.  
  1248. hasTag(name[], tags[4][32], tagsNum)
  1249. {
  1250. for (new a = 0; a < tagsNum; ++a)
  1251. if (contain(name, tags[a]) != -1)
  1252. return a
  1253. return -1
  1254. }
  1255.  
  1256. public cmdLeave(id, level, cid)
  1257. {
  1258. if (!cmd_access(id, level, cid, 2))
  1259. return PLUGIN_HANDLED
  1260.  
  1261. new argnum = read_argc()
  1262. new ltags[4][32]
  1263. new ltagsnum = 0
  1264.  
  1265. for (new a = 1; a < 5; ++a)
  1266. {
  1267. if (a < argnum)
  1268. read_argv(a, ltags[ltagsnum++], charsmax(ltags[]))
  1269. else
  1270. ltags[ltagsnum++][0] = 0
  1271. }
  1272.  
  1273. new nick[MAX_NAME_LENGTH], ires, pnum = MaxClients, count = 0, lReason[128]
  1274.  
  1275. for (new b = 1; b <= pnum; ++b)
  1276. {
  1277. if (!is_user_connected(b) && !is_user_connecting(b)) continue
  1278.  
  1279. get_user_name(b, nick, charsmax(nick))
  1280. ires = hasTag(nick, ltags, ltagsnum)
  1281.  
  1282. if (ires != -1)
  1283. {
  1284. console_print(id, "[AMXX] %L", id, "SKIP_MATCH", nick, ltags[ires])
  1285. continue
  1286. }
  1287.  
  1288. if (get_user_flags(b) & ADMIN_IMMUNITY)
  1289. {
  1290. console_print(id, "[AMXX] %L", id, "SKIP_IMM", nick)
  1291. continue
  1292. }
  1293.  
  1294. console_print(id, "[AMXX] %L", id, "KICK_PL", nick)
  1295.  
  1296. if (is_user_bot(b))
  1297. server_cmd("kick #%d", get_user_userid(b))
  1298. else
  1299. {
  1300. formatex(lReason, charsmax(lReason), "%L", b, "YOU_DROPPED")
  1301. server_cmd("kick #%d ^"%s^"", get_user_userid(b), lReason)
  1302. }
  1303. count++
  1304. }
  1305.  
  1306. console_print(id, "[AMXX] %L", id, "KICKED_CLIENTS", count)
  1307.  
  1308. new authid[32], name[MAX_NAME_LENGTH]
  1309.  
  1310. get_user_authid(id, authid, charsmax(authid))
  1311. get_user_name(id, name, charsmax(name))
  1312. 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])
  1313.  
  1314. show_activity_key("ADMIN_LEAVE_1", "ADMIN_LEAVE_2", name, ltags[0], ltags[1], ltags[2], ltags[3]);
  1315.  
  1316. return PLUGIN_HANDLED
  1317. }
  1318.  
  1319. public cmdNick(id, level, cid)
  1320. {
  1321. if (!cmd_access(id, level, cid, 3))
  1322. return PLUGIN_HANDLED
  1323.  
  1324. new arg1[32], arg2[32], authid[32], name[32], authid2[32], name2[32]
  1325.  
  1326. read_argv(1, arg1, charsmax(arg1))
  1327. read_argv(2, arg2, charsmax(arg2))
  1328.  
  1329. new player = cmd_target(id, arg1, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF)
  1330.  
  1331. if (!player)
  1332. return PLUGIN_HANDLED
  1333.  
  1334. get_user_authid(id, authid, charsmax(authid))
  1335. get_user_name(id, name, charsmax(name))
  1336. get_user_authid(player, authid2, charsmax(authid2))
  1337. get_user_name(player, name2, charsmax(name2))
  1338.  
  1339. set_user_info(player, "name", arg2)
  1340.  
  1341. 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)
  1342.  
  1343. show_activity_key("ADMIN_NICK_1", "ADMIN_NICK_2", name, name2, arg2);
  1344.  
  1345. console_print(id, "[AMXX] %L", id, "CHANGED_NICK", name2, arg2)
  1346.  
  1347. return PLUGIN_HANDLED
  1348. }
  1349.  
  1350. public cmdLast(id, level, cid)
  1351. {
  1352. if (!cmd_access(id, level, cid, 1))
  1353. {
  1354. return PLUGIN_HANDLED;
  1355. }
  1356.  
  1357. new name[MAX_NAME_LENGTH];
  1358. new authid[32];
  1359. new ip[32];
  1360. new flags[32];
  1361. new access;
  1362.  
  1363.  
  1364. // This alignment is a bit weird (it should grow if the name is larger)
  1365. // but otherwise for the more common shorter name, it'll wrap in server console
  1366. // Steam client display is all skewed anyway because of the non fixed font.
  1367. console_print(id, "%19s %20s %15s %s", "name", "authid", "ip", "access");
  1368.  
  1369. for (new i = 0; i < g_Size; i++)
  1370. {
  1371. GetInfo(i, name, charsmax(name), authid, charsmax(authid), ip, charsmax(ip), access);
  1372.  
  1373. get_flags(access, flags, charsmax(flags));
  1374.  
  1375. console_print(id, "%19s %20s %15s %s", name, authid, ip, flags);
  1376. }
  1377.  
  1378. console_print(id, "%d old connections saved.", g_Size);
  1379.  
  1380. return PLUGIN_HANDLED;
  1381. }
  1382.  
  1383. public plugin_end()
  1384. {
  1385. TrieDestroy(g_tempBans);
  1386. TrieDestroy(g_tXvarsFlags);
  1387. }
Add Comment
Please, Sign In to add comment