Guest User

Untitled

a guest
Nov 20th, 2020
84
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[MAXPLAYERS + 1][128];
  9. char samemessage[MAXPLAYERS + 1][128];
  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[client], sizeof(playermessage));
  37.    
  38.     if (spamcount[client] == 0)
  39.     {
  40.         strcopy(samemessage[client], sizeof(samemessage), playermessage[client]);
  41.         spamcount[client]++;
  42.         CreateTimer(10.0, Timer_ResetSpamcount, client);
  43.         return Plugin_Handled;
  44.     }
  45.    
  46.     if (spamcount[client] == 1)
  47.     {
  48.         if (StrEqual(playermessage[client], samemessage[client]))
  49.         {
  50.             spamcount[client]++;
  51.         }
  52.         return Plugin_Handled;
  53.     }
  54.    
  55.     if (spamcount[client] == 2)
  56.     {
  57.         if (StrEqual(playermessage[client], samemessage[client]))
  58.         {
  59.             ServerCommand("sm_gag %N", client);
  60.             ResetSpamCount(client);
  61.         }
  62.         return Plugin_Handled;
  63.     }
  64.     else
  65.     return Plugin_Handled;
  66. }
  67.  
  68. public Action Timer_ResetSpamcount(Handle timer, int client)
  69. {
  70.     ResetSpamCount(client);
  71. }
  72.  
  73. void ResetSpamCount(int client)
  74. {
  75.     spamcount[client] = 0;
  76. }
RAW Paste Data