Guest User

Untitled

a guest
Nov 20th, 2020
45
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. #pragma semicolon 1
  5. #pragma newdecls required
  6.  
  7. char spamcount[MAXPLAYERS + 1] =  { 0, ... };
  8. char playermessage[200];
  9. char samemessage[200];
  10.  
  11. public Plugin myinfo =
  12. {
  13.     name = "Anti-Spam",
  14.     author = "FAQU",
  15.     description = "Gags the player for sending the same message 3 times in less than 10 seconds."
  16. };
  17.  
  18. public void OnPluginStart()
  19. {
  20.     HookEvent("player_say", OnPlayerSay);
  21. }
  22.  
  23. public void OnClientPutInServer(int client)
  24. {
  25.     ResetSpamCount(client);
  26. }
  27.  
  28. public void OnClientDisconnect(int client)
  29. {
  30.     ResetSpamCount(client);
  31. }
  32.  
  33. public Action OnPlayerSay(Handle event, const char[] name, bool dontBroadcast)
  34. {
  35.     int client = GetClientOfUserId(GetEventInt(event, "userid"));
  36.     GetEventString(event, "text", playermessage, sizeof(playermessage));
  37.    
  38.     if (spamcount[client] == 0)
  39.     {
  40.         strcopy(samemessage, sizeof(samemessage), playermessage);
  41.         spamcount[client]++;
  42.         return Plugin_Handled;
  43.     }
  44.    
  45.     if (spamcount[client] == 1)
  46.     {
  47.         GetEventString(event, "text", playermessage, sizeof(playermessage));
  48.         if (StrEqual(playermessage, samemessage))
  49.         {
  50.             spamcount[client]++;
  51.             CreateTimer(10.0, Timer_ResetLimit, client);
  52.         }
  53.         return Plugin_Handled;
  54.     }
  55.    
  56.     if (spamcount[client] == 2)
  57.     {
  58.         GetEventString(event, "text", playermessage, sizeof(playermessage));
  59.         if (StrEqual(playermessage, samemessage))
  60.         {
  61.             ServerCommand("sm_gag %N", client);
  62.             ResetSpamCount(client);
  63.         }
  64.         return Plugin_Handled;
  65.     }
  66.     else
  67.     return Plugin_Handled;
  68. }
  69.  
  70. public Action Timer_ResetLimit(Handle timer, int client)
  71. {
  72.     ResetSpamCount(client);
  73. }
  74.  
  75. void ResetSpamCount(int client)
  76. {
  77.     spamcount[client] = 0;
  78. }
RAW Paste Data