Advertisement
Guest User

Untitled

a guest
Feb 7th, 2023
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.49 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <nvault>
  3. #include <reapi>
  4. #include <CromChat>
  5. #include <amxx4u>
  6.  
  7. // #define DEBUG_MODE
  8. #define TASK_KICK 5482
  9.  
  10. enum _:CLIENT_CVARS (+= 1)
  11. {
  12. KICK_REASON[MAX_NAME],
  13. SHOW_SUSPECTS,
  14. CLIENT_MARK[MAX_NAME],
  15. SHOW_MARK_SUSPECTS
  16. };
  17.  
  18. static const name[] = "Client Verification";
  19. static const author[] = "NewITVision";
  20.  
  21. static const save_key[] = "amxx4u_client"
  22.  
  23. static const steam_commands[][] =
  24. {
  25. "/steam",
  26. "/client",
  27. "/nsblok",
  28. "/verificaton"
  29. };
  30.  
  31. new steam_id[MAX_AUTHID];
  32.  
  33. new bool:all_players;
  34. new cvar_client[CLIENT_CVARS];
  35. new vault;
  36.  
  37. public plugin_init()
  38. {
  39. register_plugin(name, version, author);
  40.  
  41. register_commands(steam_commands, sizeof(steam_commands), "steam_menu", ADMIN_IMMUNITY);
  42. RegisterHookChain(RG_CBasePlayer_Spawn, "player_spawn", true);
  43.  
  44. _register_cvars();
  45.  
  46. vault = nvault_open("amxx4u_client");
  47. CC_SetPrefix(chat_prefix);
  48. }
  49.  
  50. public plugin_cfg()
  51. {
  52. all_players = nvault_get(vault, save_key) ? false : true;
  53.  
  54. #if defined DEBUG_MODE
  55. log_amx("%s Kick all: %s", debug_prefix, all_players ? "enabled" : "disabled");
  56. #endif
  57. }
  58.  
  59. public plugin_end()
  60. nvault_close(vault);
  61.  
  62. public player_spawn(index)
  63. {
  64. if(all_players)
  65. players_kick();
  66. }
  67.  
  68. public steam_menu(index)
  69. {
  70. new menu = menu_create(fmt("%s Client Verification", menu_title), "steam_handle");
  71.  
  72. menu_additem(menu, fmt("%s Wyrzucaj podejrzanych graczy: %s", menu_prefix, all_players ? "\rTak" : "\yNie"));
  73. menu_additem(menu, fmt("%s Wyrzuc wszystkich podejrzanych graczy", menu_prefix));
  74.  
  75. menu_addblank(menu, .slot = 0);
  76. menu_addtext(menu, fmt("%s\d Lista graczy:", menu_prefix), .slot = 0);
  77.  
  78. if(cvar_client[SHOW_SUSPECTS])
  79. {
  80. ForPlayers(i)
  81. {
  82. if(!is_user_connected(i) || check_version(i))
  83. continue;
  84.  
  85. menu_additem(menu, fmt("%s %n\d (%s)", menu_prefix, i, steam_id), fmt("%i", i));
  86. }
  87. }
  88. else
  89. {
  90. ForPlayers(i)
  91. {
  92. if(!is_user_connected(i) || is_user_hltv(i))
  93. continue;
  94.  
  95. menu_additem(menu, fmt("%s %n\d (%s)\r %s", menu_prefix, i, steam_id, check_version(i) ? "": fmt("%s", cvar_client[CLIENT_MARK])), fmt("%i", i));
  96. }
  97. }
  98.  
  99. menu_setprop(menu, MPROP_BACKNAME, fmt("%s Wroc", menu_prefix));
  100. menu_setprop(menu, MPROP_NEXTNAME, fmt("%s Dalej", menu_prefix));
  101.  
  102. menu_setprop(menu, MPROP_EXITNAME, fmt("%s Wyjdz", menu_prefix));
  103. menu_display(index, menu);
  104. }
  105.  
  106. public steam_handle(index, menu, item)
  107. {
  108. if(item == MENU_EXIT)
  109. {
  110. menu_destroy(menu);
  111. return PLUGIN_HANDLED;
  112. }
  113.  
  114. switch(item)
  115. {
  116. case 0:
  117. {
  118. all_players = !all_players;
  119. nvault_set(vault, save_key, all_players ? "0" : "1");
  120.  
  121. CC_SendMessage(index, "Wyrzucanie podejrzanych %s", all_players ? "&x04wlaczone&x01 (Od nastepnego spawna, wszyscy podejrzani zostana wyrzuceni)" : "&x07wylaczone");
  122. }
  123. case 1:
  124. {
  125. ForPlayers(i)
  126. {
  127. if(!is_user_connected(i) || is_user_hltv(i))
  128. continue;
  129.  
  130. if(check_version(i))
  131. {
  132. #if defined DEBUG_MODE
  133. log_amx("%s [ALL] Client Steam: %n", debug_prefix, i);
  134. #endif
  135.  
  136. CC_SendMessage(index, "Brak graczy do wyrzucenia.");
  137. return PLUGIN_HANDLED;
  138. }
  139.  
  140. server_cmd("amx_kick #%d ^"%s^"", get_user_userid(i), cvar_client[KICK_REASON]);
  141. return PLUGIN_HANDLED;
  142. }
  143. }
  144. default:
  145. {
  146. new data[6];
  147.  
  148. menu_item_getinfo(menu, item, _, data, charsmax(data));
  149. menu_destroy(menu);
  150.  
  151. new target = str_to_num(data);
  152.  
  153. if(!is_user_connected(target))
  154. {
  155. CC_SendMessage(index, "Wybrany gracz&x07 wyszedl&x01 z serwera.");
  156. return PLUGIN_HANDLED;
  157. }
  158.  
  159. if(check_version(target))
  160. {
  161. #if defined DEBUG_MODE
  162. log_amx("%s [ITEM] Client Steam: %n", debug_prefix, target);
  163. #endif
  164.  
  165. CC_SendMessage(index, "Wybrany gracz nie jest podejrzanym graczem.");
  166. return PLUGIN_HANDLED;
  167. }
  168.  
  169. server_cmd("amx_kick #%d ^"%s^"", get_user_userid(target), cvar_client[KICK_REASON]);
  170. }
  171. }
  172. return PLUGIN_HANDLED;
  173. }
  174.  
  175. public client_putinserver(index)
  176. {
  177. if(is_user_hltv(index))
  178. return PLUGIN_HANDLED;
  179.  
  180. get_user_authid(index, steam_id, charsmax(steam_id));
  181.  
  182. if(all_players)
  183. players_kick();
  184.  
  185. #if defined DEBUG_MODE
  186. if(check_version(index))
  187. {
  188. log_amx("%s [ERROR] Steam = Player: %n | SteamID: %s", debug_prefix, index, steam_id);
  189. return PLUGIN_HANDLED;
  190. }
  191.  
  192. log_amx("[WARNING | PUTINSERVER] Player: %n | SteamID: %s", index, steam_id);
  193. #endif
  194.  
  195. return PLUGIN_HANDLED;
  196. }
  197.  
  198. public players_kick()
  199. {
  200. if(task_exists(TASK_KICK))
  201. remove_task(TASK_KICK);
  202.  
  203. ForPlayers(i)
  204. {
  205. if(!is_user_connected(i) || is_user_hltv(i) || check_version(i))
  206. continue;
  207.  
  208. server_cmd("amx_kick #%d ^"%s^"", get_user_userid(i), cvar_client[KICK_REASON]);
  209. }
  210. }
  211.  
  212. stock bool:check_version(index)
  213. {
  214. #define get_steam(%1) containi(steam_id, %1) != -1
  215.  
  216. get_user_authid(index, steam_id, charsmax(steam_id));
  217.  
  218. if(get_steam("STEAM_0:0:") || get_steam("STEAM_0:1:") || get_steam("STEAM_1:0:") || get_steam("STEAM_2:0:"))
  219. return true;
  220.  
  221. return false;
  222. }
  223.  
  224. _register_cvars()
  225. {
  226. bind_pcvar_string(create_cvar("amxx4u_kick_reason", "Client blocked",
  227. .description = "Powód wyrzucenia podejrzanych graczy/a"), cvar_client[KICK_REASON], charsmax(cvar_client[KICK_REASON]));
  228.  
  229. bind_pcvar_num(create_cvar("amxx4u_show_suspects", "0",
  230. .description = "Wyświetlać tylko podejrzanych graczy w menu?"), cvar_client[SHOW_SUSPECTS]);
  231.  
  232. bind_pcvar_string(create_cvar("amxx4u_client_mark", "#",
  233. .description = "Znak wyświetlany przy podejrzanych"), cvar_client[CLIENT_MARK], charsmax(cvar_client[CLIENT_MARK]));
  234.  
  235. bind_pcvar_num(create_cvar("amxx4u_mark_suspects", "1",
  236. .description = "Wyświetlać znak (#) przy?"), cvar_client[SHOW_MARK_SUSPECTS]);
  237. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement