Advertisement
seroff

CMD SHOW 6.0.1F By Seroff

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