Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #pragma semicolon 1
- #pragma newdecls required
- char spamcount[MAXPLAYERS + 1] = { 0, ... };
- char playermessage[200];
- char samemessage[200];
- public Plugin myinfo =
- {
- name = "Anti-Spam",
- author = "FAQU",
- description = "Gags the player for sending the same message 3 times in less than 10 seconds."
- };
- public void OnPluginStart()
- {
- HookEvent("player_say", OnPlayerSay);
- }
- public void OnClientPutInServer(int client)
- {
- ResetSpamCount(client);
- }
- public void OnClientDisconnect(int client)
- {
- ResetSpamCount(client);
- }
- public Action OnPlayerSay(Handle event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- GetEventString(event, "text", playermessage, sizeof(playermessage));
- if (spamcount[client] == 0)
- {
- strcopy(samemessage, sizeof(samemessage), playermessage);
- spamcount[client]++;
- return Plugin_Handled;
- }
- if (spamcount[client] == 1)
- {
- GetEventString(event, "text", playermessage, sizeof(playermessage));
- if (StrEqual(playermessage, samemessage))
- {
- spamcount[client]++;
- CreateTimer(10.0, Timer_ResetLimit, client);
- }
- return Plugin_Handled;
- }
- if (spamcount[client] == 2)
- {
- GetEventString(event, "text", playermessage, sizeof(playermessage));
- if (StrEqual(playermessage, samemessage))
- {
- ServerCommand("sm_gag %N", client);
- ResetSpamCount(client);
- }
- return Plugin_Handled;
- }
- else
- return Plugin_Handled;
- }
- public Action Timer_ResetLimit(Handle timer, int client)
- {
- ResetSpamCount(client);
- }
- void ResetSpamCount(int client)
- {
- spamcount[client] = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement