laurentiuarion

AMXX Gag Ban

Feb 11th, 2020
18
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <colorchat>
  4.  
  5. //Bools
  6. new bool:g_Gaged[33];
  7. new g_GagTime[33];
  8.  
  9. //Cvars
  10. new cvar_gag_time, cvar_gag_ban_reason,cvar_gag_ban_time,cvar_ban,cvar_file,cvar_sound, cvar_tag;
  11. new g_Tag;
  12.  
  13. //Sound
  14. new const g_Sound[] = "amxx_gag_sound.wav";
  15.  
  16. //Words file
  17. new const g_FileName[] = "amx_gag_words.ini";
  18. new g_Words[64][32], g_Count;
  19.  
  20. public plugin_init() {
  21.     register_plugin("AMXX GAG BAN", "0.09.1", "Ex3cuTioN");
  22.    
  23.     //Comenzi admin
  24.     register_concmd("amx_gag", "cmdGag", ADMIN_KICK,"- <target> <minutes>" );
  25.     register_concmd("amx_ungag", "cmdUngag", ADMIN_KICK, "- <target>");
  26.    
  27.     //Comanda de chat
  28.     register_clcmd("say", "sayHandle");
  29.     register_clcmd("say_team", "sayHandle");
  30.    
  31.     //Cvar-uri
  32.     cvar_gag_time = register_cvar("amx_gag_time", "3");
  33.     cvar_ban = register_cvar("amx_gag_ban", "1");
  34.     cvar_gag_ban_reason = register_cvar("amx_gag_ban_reason", "deconectare cu gag");
  35.     cvar_gag_ban_time = register_cvar("amx_gag_ban_time", "15");
  36.     cvar_file = register_cvar("amx_gag_file", "0");
  37.     cvar_sound = register_cvar("amx_gag_sound", "1");
  38.     cvar_tag = register_cvar("amx_gag_tag", "AMXX");
  39.    
  40.     new tag[32];
  41.     g_Tag = get_pcvar_string(cvar_tag, tag, 31);
  42. }
  43.  
  44. public plugin_cfg() {
  45.     if(get_pcvar_num(cvar_file)) {
  46.         static dir[64], g_File[128];
  47.        
  48.         get_localinfo( "amxx_configsdir", dir, 63 );
  49.         formatex(g_File, 127 , "%s/%s" , dir, g_FileName);
  50.        
  51.         if(!file_exists(g_File))
  52.             write_file(g_File, "[lista de cuvinte vulgare]", -1);
  53.            
  54.         new Len;
  55.         while(g_Count < 64 && read_file(g_File, g_Count ,g_Words[g_Count][ 1 ], 30, Len)) {
  56.             g_Words[g_Count][0] = Len;
  57.             g_Count++;
  58.         }
  59.     }
  60. }
  61.  
  62. public plugin_precache()
  63.     precache_sound(g_Sound);
  64.  
  65. public client_connect(id) {
  66.     g_Gaged[id] = false;
  67.     g_GagTime[id] = 0;
  68. }
  69.  
  70. public client_disconnect(id) {
  71.     //Daca are gag primeste ban
  72.     if(get_pcvar_num(cvar_ban) && g_Gaged[id]) {
  73.         new reason[32];
  74.         get_pcvar_string(cvar_gag_ban_reason, reason, 31);
  75.        
  76.         server_cmd("amx_ban ^"%s^" %i ^"%s^"",get_name(id),get_pcvar_num(cvar_gag_ban_time),reason);
  77.        
  78.         ColorChat(0,GREEN,"[%s]^x03 %s^x01 a primit ban^x04 %d^x01 minute.Motiv : ^x04 %s",g_Tag,get_name(id),get_pcvar_num(cvar_gag_ban_time),reason);
  79.        
  80.         remove_task(id + 123);
  81.        
  82.         ColorChat(0, GREEN, "[%s]^x03 %s^x01<%s><%s> s-a deconectat dupa gag.",g_Tag,get_name(id), get_steamid(id), get_ip(id));
  83.     }
  84.    
  85.     g_Gaged[id] = false
  86.     g_GagTime[id] = 0;
  87. }
  88.  
  89. public sayHandle(id) { 
  90.     new said[192];
  91.     read_args(said, 191);
  92.    
  93.     if(!strlen(said))
  94.         return PLUGIN_CONTINUE;
  95.        
  96.     if(g_Gaged[id]) {
  97.         ColorChat(id,GREEN,"[%s]^x01 Mai ai^x04 %i^x01 minute din gag.", g_Tag, g_GagTime[id]);
  98.         return PLUGIN_HANDLED;
  99.     }
  100.     else if(get_pcvar_num(cvar_file)) {
  101.         new bool:Injura, i, pos;
  102.        
  103.         new g_Len;
  104.        
  105.         for(i = 0; i<g_Count; ++i) {
  106.             if((pos = containi(said, g_Words[i][1])) != -1) {
  107.                 g_Len = g_Words[i][0];
  108.                
  109.                 while(g_Len--)
  110.                     said[pos++] = '*';
  111.                    
  112.                 Injura = true;
  113.                 continue;
  114.             }
  115.         }
  116.        
  117.         if(Injura) {
  118.             new timp = get_pcvar_num(cvar_gag_time);
  119.             g_Gaged[id] = true;
  120.             g_GagTime[id] = timp;
  121.    
  122.             ColorChat(0,GREEN,"[%s]^x01 Jucatorul^x04 %s^x01 a primit mut pentru^x04 %i^x01 minute datorita limbajului.",g_Tag,get_name(id),timp);
  123.  
  124.             set_task(60.0, "count", id+123, _, _, "b");
  125.            
  126.             if(get_pcvar_num(cvar_sound))
  127.                 client_cmd(0, "spk ^"sound/%s^"", g_Sound);
  128.            
  129.             return PLUGIN_HANDLED;
  130.         }
  131.     }
  132.    
  133.     return PLUGIN_CONTINUE;
  134. }
  135.  
  136. public cmdGag(id, level, cid) {
  137.     if(!cmd_access(id, level, cid, 2))
  138.         return PLUGIN_HANDLED;
  139.        
  140.     new arg[32], arg2[6];
  141.    
  142.     read_argv(1, arg, 31);
  143.     read_argv(2, arg2, 5);
  144.    
  145.     new player = cmd_target(id, arg, 8);
  146.    
  147.     if(!player)
  148.         return PLUGIN_HANDLED;
  149.    
  150.     if(g_Gaged[player]) {
  151.         console_print(id,"Jucatorul %s are deja gag.",get_name(player));
  152.         return PLUGIN_HANDLED;
  153.     }
  154.    
  155.     if(equal(arg2,""))
  156.         g_GagTime[player] = get_pcvar_num(cvar_gag_time);
  157.     else
  158.         g_GagTime[player] = str_to_num(arg2);
  159.    
  160.     g_Gaged[player] = true;
  161.    
  162.     ColorChat(0,GREEN,"[%s]^x01 Jucatorul^x04 %s^x01 a primit mut de la adminul^x04 %s^x01 pentru^x04 %i^x01 minute.",g_Tag,get_name(player),get_name(id),g_GagTime[player]);
  163.  
  164.     set_task(60.0, "count", player+123, _, _, "b");
  165.    
  166.     if(get_pcvar_num(cvar_sound))
  167.         client_cmd(0, "spk ^"sound/%s^"", g_Sound);
  168.    
  169.     return PLUGIN_HANDLED;
  170. }
  171.  
  172. public cmdUngag(id,level, cid) {
  173.     if(!cmd_access(id, level, cid, 2))
  174.         return PLUGIN_HANDLED;
  175.        
  176.     new arg[32];
  177.     read_argv(1, arg, 31);
  178.    
  179.     new player = cmd_target(id, arg, 8);
  180.    
  181.     if(!player)
  182.         return PLUGIN_HANDLED;
  183.        
  184.     if(!g_Gaged[player]) {
  185.         console_print( id, "Jucatorul %s nu are mut.",get_name(player));
  186.         return PLUGIN_HANDLED;
  187.     }
  188.    
  189.     g_Gaged[player] = false;
  190.    
  191.     remove_task(player + 123);
  192.    
  193.     ColorChat(0,GREEN,"[%s]^x03 %s^x01 ii da voie sa vorbeasca lui^x04 %s.",g_Tag,get_name(id),get_name(player));
  194.    
  195.     return PLUGIN_HANDLED;
  196. }
  197.    
  198. public count(task) {
  199.     new player = task - 123;
  200.    
  201.     if(!is_user_connected(player))
  202.         return PLUGIN_HANDLED;
  203.        
  204.     g_GagTime[player] -= 1;
  205.    
  206.     if(g_GagTime[player] <= 0) {
  207.         remove_task(player + 123);
  208.        
  209.         ColorChat(0,GREEN,"[%s]^x01 Jucatorul^x04 %s^x01 are voie sa vorbeasca.",g_Tag,get_name(player));
  210.         g_Gaged[player] = false;
  211.  
  212.         return PLUGIN_HANDLED;
  213.     }
  214.    
  215.     return PLUGIN_CONTINUE;
  216. }
  217.  
  218. stock get_name(id) {
  219.     new name[32];
  220.    
  221.     get_user_name(id,name,31);
  222.    
  223.     return name;
  224. }
  225.  
  226. stock get_steamid(id) {
  227.     static steamid[32];
  228.    
  229.     get_user_authid(id,steamid,31);
  230.    
  231.     return steamid;
  232. }
  233.  
  234. stock get_ip(id) {
  235.     static ip[32];
  236.    
  237.     get_user_ip(id,ip,31);
  238.    
  239.     return ip;
  240. }
RAW Paste Data