Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.51 KB | None | 0 0
  1. #include <amxmodx>
  2.  
  3. #include <amxmisc>
  4. #include <cstrike>
  5.  
  6. #define PLUGIN "Reason_Kicker"
  7. #define AUTHOR "Tramp"
  8. #define VERSION "0.1"
  9.  
  10. new g_menuPosition[33];
  11. new g_menuPlayers[33][32];
  12. new g_menuPlayersNum[33];
  13. new g_coloredMenus;
  14. new g_kickReasons[7][128];
  15. new g_lastCustom[33][128];
  16. new g_inCustomReason[33];
  17. new g_kickedPlayer;
  18.  
  19. #define MAXSLOTS 32
  20.  
  21. enum Color
  22. {
  23. YELLOW = 1, // Yellow
  24. GREEN, // Green Color
  25. TEAM_COLOR, // Red, grey, blue
  26. GREY, // grey
  27. RED, // Red
  28. BLUE, // Blue
  29. }
  30.  
  31. new TeamInfo;
  32. new SayText;
  33. new MaxSlots;
  34.  
  35. new TeamName[][] =
  36. {
  37. "",
  38. "TERRORIST",
  39. "CT",
  40. "SPECTATOR"
  41. }
  42.  
  43. new bool:IsConnected[MAXSLOTS + 1];
  44.  
  45.  
  46. public plugin_init()
  47. {
  48. register_dictionary("common.txt")
  49. register_dictionary("admincmd.txt")
  50. register_dictionary("plmenu.txt")
  51. register_plugin(PLUGIN, VERSION, AUTHOR)
  52. register_cvar(PLUGIN, VERSION, FCVAR_SERVER|FCVAR_SPONLY);
  53. register_clcmd("amx_kickmenu", "cmdKickMenu", ADMIN_KICK, "- displays kick menu")
  54. register_clcmd("amx_customkickreason", "setCustomKickReason", ADMIN_KICK, "- configures custom ban message")
  55. register_menucmd(register_menuid("Kick Menu"), 1023, "actionKickMenu")
  56. register_menucmd(register_menuid("Kick Reason Menu"), 1023, "actionKickMenuReason")
  57.  
  58. register_cvar("amx_kick_r1","");
  59. register_cvar("amx_kick_r2","");
  60. register_cvar("amx_kick_r3","");
  61. register_cvar("amx_kick_r4","");
  62. register_cvar("amx_kick_r5","");
  63. register_cvar("amx_kick_r6","");
  64. register_cvar("amx_kick_r7","");
  65.  
  66. new k1[32], k2[32], k3[32], k4[32], k5[32], k6[32], k7[32];
  67.  
  68. get_cvar_string("amx_kick_r1",k1, 31);
  69. get_cvar_string("amx_kick_r2",k2, 31);
  70. get_cvar_string("amx_kick_r3",k3, 31);
  71. get_cvar_string("amx_kick_r4",k4, 31);
  72. get_cvar_string("amx_kick_r5",k5, 31);
  73. get_cvar_string("amx_kick_r6",k6, 31);
  74. get_cvar_string("amx_kick_r7",k7, 31);
  75.  
  76. set_task(320.0, "ads", 7777, "", 0, "b");
  77.  
  78. g_kickReasons[0] = k1
  79. g_kickReasons[1] = k2
  80. g_kickReasons[2] = k3
  81. g_kickReasons[3] = k4
  82. g_kickReasons[4] = k5
  83. g_kickReasons[5] = k6
  84. g_kickReasons[6] = k7
  85.  
  86. TeamInfo = get_user_msgid("TeamInfo");
  87. SayText = get_user_msgid("SayText");
  88. MaxSlots = get_maxplayers();
  89. }
  90.  
  91. public cmdKickMenu(id, level, cid)
  92. {
  93. if (cmd_access(id, level, cid, 1))
  94. displayKickMenu(id, g_menuPosition[id] = 0)
  95.  
  96. return PLUGIN_HANDLED
  97. }
  98.  
  99. public ads()
  100. {
  101.  
  102. for (new i = 1; i <= 32; i++)
  103. {
  104. if (is_user_connected(i))
  105. {
  106. ColorChat(i, GREY, " ");
  107. ColorChat(i, GREY, " ");
  108. }
  109. }
  110.  
  111.  
  112. }
  113.  
  114. displayKickMenu(id, pos)
  115. {
  116. if (pos < 0)
  117. return
  118.  
  119. get_players(g_menuPlayers[id], g_menuPlayersNum[id])
  120.  
  121. new menuBody[512]
  122. new b = 0
  123. new i
  124. new name[32]
  125. new start = pos * 8
  126.  
  127. if (start >= g_menuPlayersNum[id])
  128. start = pos = g_menuPosition[id] = 0
  129.  
  130. new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "KICK_MENU", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0)))
  131. new end = start + 8
  132. new keys = MENU_KEY_0
  133.  
  134. if (end > g_menuPlayersNum[id])
  135. end = g_menuPlayersNum[id]
  136.  
  137. for (new a = start; a < end; ++a)
  138. {
  139. i = g_menuPlayers[id][a]
  140. get_user_name(i, name, 31)
  141.  
  142. if (access(i, ADMIN_IMMUNITY))
  143. {
  144. ++b
  145.  
  146. if (g_coloredMenus)
  147. len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
  148. else
  149. len += format(menuBody[len], 511-len, "#. %s^n", name)
  150. } else {
  151. keys |= (1<<b)
  152.  
  153. if (is_user_admin(i))
  154. len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
  155. else
  156. len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
  157. }
  158. }
  159.  
  160. if (end != g_menuPlayersNum[id])
  161. {
  162. format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
  163. keys |= MENU_KEY_9
  164. }
  165. else
  166. format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
  167.  
  168. show_menu(id, keys, menuBody, -1, "Kick Menu")
  169. }
  170.  
  171. public actionKickMenu(id, key)
  172. {
  173. switch (key)
  174. {
  175. case 8: displayKickMenu(id, ++g_menuPosition[id])
  176. case 9: displayKickMenu(id, --g_menuPosition[id])
  177. default:
  178. {
  179. /* new player = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
  180. new authid[32], authid2[32], name[32], name2[32]
  181.  
  182. get_user_authid(id, authid, 31)
  183. get_user_authid(player, authid2, 31)
  184. get_user_name(id, name, 31)
  185. get_user_name(player, name2, 31)
  186.  
  187. new userid2 = get_user_userid(player)
  188.  
  189. log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, userid2, authid2)
  190.  
  191. show_activity_key("ADMIN_KICK_1", "ADMIN_KICK_2", name, name2);
  192.  
  193.  
  194. server_cmd("kick #%d", userid2)
  195. server_exec() */
  196.  
  197. g_kickedPlayer = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
  198.  
  199. displayKickMenuReason(id)
  200. }
  201. }
  202.  
  203. return PLUGIN_HANDLED
  204. }
  205.  
  206. displayKickMenuReason(id)
  207. {
  208. new menuBody[1024]
  209. new len = format(menuBody,1023, g_coloredMenus ? "\y%s\R^n\w^n" : "%s^n^n", "Reason")
  210. new i = 0;
  211.  
  212. while (i < 7)
  213. {
  214. if (strlen(g_kickReasons[i]))
  215. len+=format(menuBody[len],1023-len,"%d. %s^n",i+1,g_kickReasons[i])
  216.  
  217. i++
  218. }
  219.  
  220. len+=format(menuBody[len],1023-len,"^n8. Custom^n")
  221. if (g_lastCustom[id][0]!='^0')
  222. len+=format(menuBody[len],1023-len,"^n9. %s^n",g_lastCustom[id])
  223.  
  224. len+=format(menuBody[len],1023-len,"^n0. %L^n",id,"EXIT")
  225.  
  226. len+=format(menuBody[len],1023-len, g_coloredMenus ? "^n\yTramp Kicker ver %s^n" : "^nTramp Kicker ver %s\w^n", VERSION)
  227.  
  228. new keys = MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0
  229.  
  230. if (g_lastCustom[id][0]!='^0')
  231. keys |= MENU_KEY_9
  232.  
  233. show_menu(id,keys,menuBody,-1,"Kick Reason Menu")
  234. }
  235.  
  236. public actionKickMenuReason(id,key)
  237. {
  238. switch (key)
  239. {
  240. case 9:
  241. {
  242. displayKickMenu(id,g_menuPosition[id])
  243. }
  244.  
  245. case 7:
  246. {
  247. g_inCustomReason[id]=1
  248. client_cmd(id,"messagemode amx_customkickreason")
  249.  
  250. return PLUGIN_HANDLED
  251. }
  252.  
  253. case 8:
  254. {
  255. kickUser(id,g_lastCustom[id])
  256. }
  257.  
  258. default:
  259. {
  260. kickUser(id,g_kickReasons[key])
  261. }
  262. }
  263. displayKickMenu(id,g_menuPosition[id] = 0)
  264.  
  265. return PLUGIN_HANDLED
  266. }
  267.  
  268. public setCustomKickReason(id,level,cid)
  269. {
  270. if (!cmd_access(id,level,cid,1))
  271. {
  272. return PLUGIN_HANDLED
  273. }
  274.  
  275. new szReason[128]
  276. read_argv(1,szReason,127)
  277. copy(g_lastCustom[id],127,szReason)
  278.  
  279. if (g_inCustomReason[id])
  280. {
  281. g_inCustomReason[id]=0
  282. kickUser(id,g_lastCustom[id])
  283. }
  284.  
  285. return PLUGIN_HANDLED
  286. }
  287.  
  288. kickUser(id,kickReason[])
  289. {
  290. new player = g_kickedPlayer;
  291.  
  292. new name[32], name2[32], authid[32],authid2[32]
  293. get_user_name(player,name2,31)
  294. get_user_authid(player,authid2,31)
  295. get_user_authid(id,authid,31)
  296. get_user_name(id,name,31)
  297.  
  298.  
  299. new userid2 = get_user_userid(player);
  300. //client_print(0,print_chat,"Twoje id : %d ", userid2);
  301.  
  302. log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>Powod: %s^"", name, get_user_userid(id), authid, name2, userid2, authid2, kickReason)
  303.  
  304. //set_hudmessage(0, 255, 0, 0.05, 0.35, 0, 6.0, 5.0, 0.5, 0.15, 7);
  305. //show_hudmessage(0, "Gracz o nicku %s ^nZostal wywalony przez ADMINA ^nPowod: %s", name2, kickReason);
  306. //client_print(0,print_chat,"Gracz o nicku %s ^nZostal wywalony przez %s ^nPowod: %s", name2, name, kickReason);
  307.  
  308. server_cmd("kick #%d ^"%s^"",userid2,kickReason)
  309.  
  310.  
  311. }
  312.  
  313. public client_putinserver(player)
  314. {
  315. IsConnected[player] = true;
  316. }
  317.  
  318. public client_disconnect(player)
  319. {
  320. IsConnected[player] = false;
  321. }
  322.  
  323. public ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
  324. {
  325. static message[256];
  326.  
  327. switch(type)
  328. {
  329. case YELLOW: // Yellow
  330. {
  331. message[0] = 0x01;
  332. }
  333. case GREEN: // Green
  334. {
  335. message[0] = 0x04;
  336. }
  337. default: // White, Red, Blue
  338. {
  339. message[0] = 0x03;
  340. }
  341. }
  342.  
  343. vformat(message[1], 251, msg, 4);
  344.  
  345. // Make sure message is not longer than 192 character. Will crash the server.
  346. message[192] = '^0';
  347.  
  348. new team, ColorChange, index, MSG_Type;
  349.  
  350. if(!id)
  351. {
  352. index = FindPlayer();
  353. MSG_Type = MSG_ALL;
  354.  
  355. } else {
  356. MSG_Type = MSG_ONE;
  357. index = id;
  358. }
  359.  
  360. team = get_user_team(index);
  361. ColorChange = ColorSelection(index, MSG_Type, type);
  362.  
  363. ShowColorMessage(index, MSG_Type, message);
  364.  
  365. if(ColorChange)
  366. {
  367. Team_Info(index, MSG_Type, TeamName[team]);
  368. }
  369. }
  370.  
  371. ShowColorMessage(id, type, message[])
  372. {
  373. message_begin(type, SayText, _, id);
  374. write_byte(id)
  375. write_string(message);
  376. message_end();
  377. }
  378.  
  379. Team_Info(id, type, team[])
  380. {
  381. message_begin(type, TeamInfo, _, id);
  382. write_byte(id);
  383. write_string(team);
  384. message_end();
  385.  
  386. return 1;
  387. }
  388.  
  389. ColorSelection(index, type, Color:Type)
  390. {
  391. switch(Type)
  392. {
  393. case RED:
  394. {
  395. return Team_Info(index, type, TeamName[1]);
  396. }
  397. case BLUE:
  398. {
  399. return Team_Info(index, type, TeamName[2]);
  400. }
  401. case GREY:
  402. {
  403. return Team_Info(index, type, TeamName[0]);
  404. }
  405. }
  406.  
  407. return 0;
  408. }
  409.  
  410. FindPlayer()
  411. {
  412. new i = -1;
  413.  
  414. while(i <= MaxSlots)
  415. {
  416. if(IsConnected[++i])
  417. {
  418. return i;
  419. }
  420. }
  421.  
  422. return -1;
  423. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement