Advertisement
Filiq_

Untitled

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