Advertisement
Guest User

Untitled

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