seroff

CMD SHOW 5.5.1F By Seroff

Mar 28th, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.43 KB | None | 0 0
  1. #include <amxmodx>
  2.  
  3. #define LOG_FILE "addons/amxmodx/logs/cmd_show_logs.log"
  4.  
  5. #define szFlag ADMIN_KICK
  6. #define is_user_admin(%0) (get_user_flags(%0) & szFlag)
  7. new i_isBanned[33]=0, i_logs, i_bad, i_banreason, i_banmess,i_bantime,i_con,i_info,i_Immunity,Trie:szNotShow,Trie:szBadCommands,Trie:szBadCont;
  8.  
  9. new PLUGIN[][]={
  10. "CMD SHOW",
  11. "5.5.1F",
  12. "Seroff"
  13. };
  14.  
  15.  
  16. #if (AMXX_VERSION_NUM > 182)
  17. #define client_disconnect(%1) client_disconnected(%1, bool:drop, message[], maxlen)
  18. #endif
  19.  
  20. static sLen,s_file[][]={"cmd_show.cfg","Not_show.ini","Bad_show.ini","Containi.ini"}
  21.  
  22. public plugin_init(){
  23. register_plugin(PLUGIN[0],PLUGIN[1],PLUGIN[2]);
  24. i_logs=register_cvar("cmd_logs_enabled","1");
  25. i_bad=register_cvar("cmd_badshow_use","1");
  26. i_banreason=register_cvar("cmd_reason","");
  27. i_banmess=register_cvar("cmd_banmess","amx_bam [time] [userid] [reason]");
  28. i_bantime=register_cvar("cmd_bantime","10080");
  29. i_info=register_cvar("cmd_infotype","1");
  30. i_Immunity=register_cvar("cmd_adm_immunity","0");
  31. i_con=register_cvar("cmd_containi","1");
  32. szNotShow=TrieCreate();
  33. szBadCommands=TrieCreate();
  34. szBadCont=TrieCreate();
  35. }
  36.  
  37. public plugin_cfg(){
  38. new sDirs[36],szCFGFile[64],szBadFile[64],szNotShowFile[64],szBadContFile[64];
  39. get_configsdir(sDirs, charsmax(sDirs));
  40. formatex(sDirs, charsmax(sDirs), "%s/Guard",sDirs);
  41. if(!dir_exists(sDirs))mkdir(sDirs);
  42. formatex(szCFGFile,charsmax(szCFGFile),"%s/%s",sDirs,s_file[0])
  43. formatex(szNotShowFile,charsmax(szNotShowFile),"%s/%s",sDirs,s_file[1])
  44. formatex(szBadFile,charsmax(szBadFile),"%s/%s",sDirs,s_file[2])
  45. formatex(szBadContFile,charsmax(szBadContFile),"%s/%s",sDirs,s_file[3])
  46. if(!file_exists(szCFGFile)){
  47. new szFileLines[1024];
  48. formatex(szFileLines,charsmax(szFileLines),"// %s v%s By %s^ncmd_logs_enabled ^"1^" // Включить логи?^ncmd_badshow_use ^"1^" // Проверять на плохие команды^ncmd_reason ^"^" // Оставтье пустым если не хотите одну причину!^ncmd_banmess ^"amx_ban [time] [userid] [reason]^" // Наказание игрока^ncmd_bantime ^"10080^" // Время бана если тип наказания не равен 0^ncmd_infotype ^"1^" // Куда сообщать админам: 0 - в чат и в консоль, 1 - в консоль, 2 - в чат^ncmd_adm_immunity ^"0^" // Иммунитет для админов^ncmd_containi ^"1^" // Наказывать за часть команды^n^n^necho ^"^"^necho ^"CMD SHOW Config Executed^"^necho ^"^"^n",PLUGIN[0],PLUGIN[1],PLUGIN[2]);
  49. new fileid = fopen(szCFGFile,"at");
  50. if(fileid){
  51. fputs(fileid,szFileLines);
  52. }
  53. fclose(fileid);
  54. }
  55. new sFSTATE[128];
  56. formatex(sFSTATE,charsmax(sFSTATE),"File ^"%s^" not found",s_file[1]);
  57. if(!file_exists(szNotShowFile)) set_fail_state(sFSTATE);
  58. if(file_exists(szBadFile)){
  59. new iFilePointer = fopen( szBadFile, "r");
  60. if(iFilePointer != 0){
  61. new szData[128];
  62. while(fgets(iFilePointer, szData, 127)){
  63. replace(szData, 127, "^n", "");
  64. replace(szData, 127, "^t", "");
  65. remove_quotes(szData);
  66. trim(szData);
  67. strtolower(szData);
  68. TrieSetCell(szBadCommands, szData, 1);
  69. }
  70. fclose(iFilePointer);
  71. }
  72. }
  73. if(file_exists(szNotShowFile)){
  74. new iFilePointer = fopen( szNotShowFile, "r");
  75. if(iFilePointer != 0){
  76. new szData[128];
  77. while(fgets(iFilePointer, szData, 127)){
  78. replace(szData, 127, "^n", "");
  79. replace(szData, 127, "^t", "");
  80. remove_quotes(szData);
  81. trim(szData);
  82. TrieSetCell(szNotShow, szData, 1);
  83. }
  84. fclose(iFilePointer);
  85. }
  86. }
  87. if(file_exists(szBadContFile)){
  88. new sLine[10],iFilePointer = fopen( szBadContFile, "r");
  89. if(iFilePointer != 0){
  90. new szData[128];
  91. while(fgets(iFilePointer, szData, 127)){
  92. replace(szData, 127, "^n", "");
  93. replace(szData, 127, "^t", "");
  94. remove_quotes(szData);
  95. trim(szData);
  96. strtolower(szData);
  97. if(strlen(szData)>2){
  98. sLen++
  99. num_to_str ( sLen-1, sLine, charsmax(sLine) );
  100. TrieSetString(szBadCont,sLine,szData);
  101. }
  102. }
  103. fclose(iFilePointer);
  104. }
  105. }
  106. server_cmd("exec %s",szCFGFile); server_exec();
  107. return 0;
  108. }
  109.  
  110. public client_command(id){
  111. if(!is_user_connected(id) || is_user_hltv(id) || get_pcvar_num(i_Immunity)==1&&is_user_admin(id)) return 0;
  112. new name[32],cmd[128], temp[128],s_Buffer[64],sTemp[128],sLine[10];
  113. get_user_name(id, name, sizeof(name)-1);
  114. new szFile_cmd[]="addons/amxmodx/configs/Guard/checking_logcmd.txt"
  115. read_argv(0, temp, 127);
  116. if(!temp[0] || strlen(temp) == 0)return 0;
  117. if(TrieKeyExists(szNotShow, temp)){
  118. replace_all(temp, charsmax(temp), temp, "");
  119. return 0;
  120. }
  121. remove_quotes(temp); trim(temp);
  122. replace_all(temp, charsmax(temp), "#", "");
  123. replace_all(temp, charsmax(temp), "%", "");
  124. format(sTemp,charsmax(sTemp),"%s",temp);
  125. strtolower(sTemp);
  126. if(get_pcvar_num(i_bad)==1){
  127. if(TrieKeyExists(szBadCommands, sTemp)){
  128. PunishPlayer(id,temp);
  129. return 0;
  130. }
  131. }
  132. if(get_pcvar_num(i_con)==1){
  133. for(new d=0;d<sLen;d++){
  134. num_to_str ( d, sLine, charsmax(sLine) );
  135. TrieGetString(szBadCont,sLine,s_Buffer,charsmax(s_Buffer));
  136. if(containi(sTemp, s_Buffer) != -1){
  137. PunishPlayer(id,temp);
  138. return 0;
  139. }
  140. }
  141. }
  142. for(new i=0; i < read_argc (); i++){
  143. read_argv(i, temp, 127);
  144. format(cmd, 127, "%s %s", cmd, temp);
  145. }
  146. if(get_pcvar_num(i_logs)){
  147. log_to_file(LOG_FILE,"%s >> %s: [%s ]", is_user_admin(id) ? "Admin" : "Player", name, cmd)
  148. write_file(szFile_cmd, cmd);
  149. }
  150. for(new client=1; client < 33; client++){
  151. if(is_user_admin(client)){
  152. new content_msg[192];
  153. formatex(content_msg,sizeof(content_msg)-1,"^3%s ^1>> ^4%s^1: [^3%s ^1]", get_user_flags(id) & szFlag ? "Admin" : "Player", name, cmd);
  154. switch(get_pcvar_num(i_info)){
  155. case 0:{
  156. user_console(client,content_msg);
  157. ChatColor(client,content_msg);
  158. }
  159. case 1:{
  160. user_console(client,content_msg);
  161. }
  162. case 2:{
  163. ChatColor(client,content_msg);
  164. }
  165. }
  166. }
  167. }
  168. return 0;
  169. }
  170.  
  171. public client_disconnect(id){
  172. i_isBanned[id]=0;
  173. }
  174.  
  175. stock PunishPlayer(id, const szReason[],any:...){
  176. if(i_isBanned[id])return;
  177. i_isBanned[id]=1;
  178. new szUserId[10], szSteam[33], szIp[17], szTime[10], szBanString[128],izReason[128],sName[32];
  179. formatex(szUserId, charsmax(szUserId), "#%d", get_user_userid(id));
  180. get_pcvar_string(i_banmess,szBanString,charsmax(szBanString));
  181. get_pcvar_string(i_banreason,izReason,charsmax(izReason));
  182. get_user_authid(id, szSteam, charsmax(szSteam));
  183. get_user_ip(id, szIp, charsmax(szIp), 1);
  184. get_user_name(id,sName,31);
  185. num_to_str(get_pcvar_num(i_bantime), szTime, charsmax(szTime));
  186. replace_string(szBanString, charsmax(szBanString), "[userid]", szUserId);
  187. replace_string(szBanString, charsmax(szBanString), "[steam]", szSteam);
  188. replace_string(szBanString, charsmax(szBanString), "[ip]", szIp);
  189. server_print("%s %d",izReason,strlen(izReason));
  190. if(strlen(izReason)){
  191. replace_string(szBanString, charsmax(szBanString), "[reason]", izReason);
  192. }else{
  193. replace_string(szBanString, charsmax(szBanString), "[reason]", szReason);
  194. }
  195. replace_string(szBanString, charsmax(szBanString), "[time]", szTime);
  196. if(is_user_alive(id))user_kill(id,1);
  197. ChatColor(0, "^4Внимание:^1 Игрок ^3%s^1 наказан по причине ^3[^4%s^3]^1!", sName, strlen(izReason) ? izReason : szReason);
  198. server_cmd("%s", szBanString);
  199. }
  200.  
  201. stock user_console(id,const msg_content[],any:...){
  202. new msg[192];
  203. vformat(msg, sizeof(msg)-1, msg_content, 3);
  204. format(msg,sizeof(msg)-1,"%s^n",msg);
  205. message_begin(MSG_ONE, 8, {0,0,0}, id);
  206. write_string(msg);
  207. message_end();
  208. }
  209. stock get_configsdir(name[],len){
  210. return get_localinfo("amxx_configsdir",name,len);
  211. }
  212.  
  213. public plugin_end() {
  214. TrieDestroy(szBadCommands);
  215. TrieDestroy(szNotShow);
  216. TrieDestroy(szBadCont);
  217. }
  218.  
  219. /* Сток цветного чата */
  220. stock ChatColor(const id, const input[], any:...)
  221. {
  222. new count = 1, players[32]
  223. static msg[191]
  224. vformat(msg, 190, input, 3)
  225. replace_all(msg, 190, "!g", "^4") // Зелёный
  226. replace_all(msg, 190, "!y", "^1") // Стандартный
  227. replace_all(msg, 190, "!t", "^3") // Цвет команды
  228. if (id) players[0] = id; else get_players(players, count, "ch")
  229. {
  230. for (new i = 0; i < count; i++)
  231. {
  232. if (is_user_connected(players[i]))
  233. {
  234. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
  235. write_byte(players[i]);
  236. write_string(msg);
  237. message_end();
  238. }
  239. }
  240. }
  241. }
Advertisement
Add Comment
Please, Sign In to add comment