HoangNamMapper

[SA-MP] Anti MG/Swear/Spam

Sep 29th, 2016
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.25 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4.  
  5. #if defined FILTERSCRIPT
  6. #endif
  7. enum Info
  8. {
  9.    AdminLevel,
  10. }
  11.  
  12. new Warnings;
  13. new SpamCount[MAX_PLAYERS];
  14. new ChatSpamTime[MAX_PLAYERS][3];
  15. new muted[MAX_PLAYERS];
  16. #define AutoUnmuteTime 2
  17. new string[128];
  18. new PlayerInfo[MAX_PLAYERS][Info];
  19. #define MAX_MG 3
  20. new MG [] = //You can add more symbols, characters in here
  21. {
  22.     "PG",
  23.     "MG",
  24.     "RK",
  25.     "admin",
  26.     "id",
  27.     "hack",
  28.     "bug",
  29.     "SK",
  30.     "BK",
  31.     "fuck",
  32.     "bitch",
  33.     "gay",
  34.     "stupid",
  35.     "@",
  36.     "#",
  37.     "^",
  38.     "&",
  39. };
  40. public OnPlayerText(playerid, text[])
  41. {
  42.         for(new i = 0; i < sizeof(MG); i++)
  43.     {
  44.        if(strfind(text, MG[i], true) != -1 && PlayerInfo[playerid][AdminLevel] == 0)
  45.         {
  46.             Warnings++;
  47.             format(string, sizeof(string), "{FF0000}[Info]: {FFFFFF}Meta Gaming! {FF0000}WARNINGS: {15FF00}[%d/%d]", Warnings, MAX_MG);
  48.             SendClientMessage(playerid, -1, string);
  49.             return 0;
  50.         }
  51.     }
  52.        
  53.         if(muted[playerid] == 1)
  54.     {
  55.         SendClientMessage(playerid, 0xFF0000FF, "You have been muted!(Reason:SPAM)");
  56.         return 0;
  57.     }
  58.     else
  59.     {
  60.         if(PlayerInfo[playerid][AdminLevel] == 0)
  61.         {
  62.             AntiSpam(playerid);
  63.         }
  64.     }
  65.  
  66.         return 1;
  67.  
  68. }
  69.  
  70. public OnPlayerSpawn(playerid)
  71. {
  72.         SetTimerEx("Check", 2000, false, "i", playerid);
  73.         return 1;
  74. }
  75. forward Check(playerid);
  76. public Check(playerid)
  77. {
  78.         new string[128], name[MAX_PLAYER_NAME];
  79.         GetPlayerName(playerid, name, sizeof(name));
  80.         if(Warnings == MAX_MG)
  81.         {
  82.                 format(string, sizeof(string), "{FF0000}[Info]:{FF0000}%s {FFFFFF}has been kicked {FF0000}Reason: MG.", name);
  83.                 SendClientMessageToAll(-1, string);
  84.                 Kick(playerid);
  85.         }
  86.         return 1;
  87. }
  88.  
  89. stock AntiSpam(playerid)
  90. {
  91.     SpamCount[playerid]++;
  92.     switch (SpamCount[playerid])
  93.     {
  94.         case 1:
  95.         {
  96.             ChatSpamTime[playerid][0]=gettime();
  97.         }
  98.         case 2:
  99.         {
  100.             if((gettime()-ChatSpamTime[playerid][0])<5)
  101.             {
  102.                 SendClientMessage(playerid,0xFF0000FF,"You are having some warnings (1/3)! (Reason: Spam)");
  103.                 ChatSpamTime[playerid][1]=gettime();
  104.             }
  105.             else SpamCount[playerid]=0;
  106.         }
  107.         case 3:
  108.         {
  109.             if((gettime()-ChatSpamTime[playerid][1])<5)
  110.             {
  111.                 SendClientMessage(playerid,0xFF0000FF,"You are having some warning (2/3)! (Reason: Spam)");
  112.                 ChatSpamTime[playerid][2]=gettime();
  113.             }
  114.             else SpamCount[playerid]=0;
  115.         }
  116.         case 4..50:
  117.         {
  118.             new string[128],name[24];
  119.             GetPlayerName(playerid,name,24);
  120.             if((gettime()-ChatSpamTime[playerid][2])<5)
  121.             {
  122.                 format(string,sizeof(string),"Player %s has been muted for 2 minutes! (Reason: Spam!)",name);
  123.                 SendClientMessageToAll(0xFF0000FF,string);
  124.                 SendClientMessage(playerid,0xFF0000FF,"You have received your final warning (3/3)! (Reason: Spam)");
  125.                 muted[playerid]=1;
  126.                 SetTimerEx("AutoUnMute",AutoUnmuteTime*60000,false,"i",playerid);
  127.             }
  128.         }
  129.     }
  130.     return 1;
  131. }
  132. public OnPlayerConnect(playerid)
  133. {
  134.     SpamCount[playerid]=0;
  135.     muted[playerid]=0;
  136.     return 1;
  137. }
  138.  
  139. forward AutoUnMute(pID);
  140. public AutoUnMute(pID)
  141. {
  142.     muted[pID] = 0;
  143.     SpamCount[pID]=0;
  144.     SendClientMessage(pID, 0xFF0000FF, "Now you can talk, but don't Spam again!");
  145.     return 1;
  146. }
Advertisement
Add Comment
Please, Sign In to add comment