Author Topic: Spam Meter  (Read 2885 times)

0 Members and 1 Guest are viewing this topic.

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Spam Meter
« on: August 13, 2007, 05:54:35 pm »
Script Name: Spam Meter
Script Description: Allows for better control over spammers. Every message their meter is increased by a defined percent and every second decreased by a defined percent. Once it reaches the defined end value they are global muted for a predefined amount of time.
Original Author(s): EagleEye (Thanks to Avarax for original idea)
Core Version: 2.6.2
Code:

* Necessary files are attached

Code: [Select]
const
START_VALUE = 25; //start value for spam meter
END_VALUE = 100; //value at which player gets muted
PERCENT_INCREASE = 30; //percent to increase per chat message
PERCENT_DECREASE = 5; //percent to decrease every second
MUTE_TIME = 30; //time in seconds to mute spammer
UNMUTE_ON_LEAVE = true; //unmute player wen they leave the game?

var
SpamMeter: Array [1..32] of single;
MuteTime: Array [1..32] of integer;
i: integer;

procedure AppOnIdle(Ticks: integer);
begin
for i:=1 to 32 do begin

if (SpamMeter[i] = -1) then begin
if MuteTime[i] > 0 then MuteTime[i] := MuteTime[i] - 1
else begin
Command('/ungmute ' + inttostr(i));
SayToPlayer(i,'You have been unmuted');
SpamMeter[i] := 0;
end;
end;

if SpamMeter[i] > END_VALUE then begin
Command('/gmute ' + inttostr(i));
SayToPlayer(i,'You have been muted for ' + inttostr(MUTE_TIME) + ' seconds for spamming');
SpamMeter[i] := -1;
MuteTime[i] := MUTE_TIME;
end;

if SpamMeter[i] > START_VALUE then begin
SpamMeter[i] := SpamMeter[i] * (1.0 - PERCENT_DECREASE / 100.0);
if SpamMeter[i] < START_VALUE then SpamMeter[i] := START_VALUE;
end;

end;
end;

procedure OnJoinGame(ID, Team: byte);
begin
SpamMeter[ID] := 0;
MuteTime[ID] := 0;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
if (SpamMeter[ID] = -1) and (UNMUTE_ON_LEAVE = true) then Command('/ungmute ' + inttostr(ID));
SpamMeter[ID] := 0;
MuteTime[ID] := 0;
end;

procedure OnPlayerSpeak(ID: byte; Text: string);
begin
if SpamMeter[ID] <> -1 then begin
if SpamMeter[ID] >= START_VALUE then SpamMeter[ID] := SpamMeter[ID] * (1.0 + PERCENT_INCREASE / 100.0)
else SpamMeter[ID] := START_VALUE;
if (SpamMeter[ID] < 100) and (SpamMeter[ID] * (1.0 + PERCENT_INCREASE / 100.0) > END_VALUE) then SayToPlayer(ID,'WARNING: Do not spam');
end;
end;

« Last Edit: August 13, 2007, 10:42:59 pm by mikembm »

Offline Will

  • Flagrunner
  • ****
  • Posts: 910
Re: Spam Meter
« Reply #1 on: August 13, 2007, 06:18:30 pm »
sounds great for servers not visited by admins so often. I also suggest a cumulative function for increasing the mute time every time a person gets muted because of spaming. So the first mute could be a warning and a message could be displayed saying the player has been warned for spam and muted for X amount of time. Also would be good if the player was muted once, the percentage of the spam meter or the time needed for the percentage to go down would increase.

Is it possible to filter out and not include messages containing EFC, up, down and that stuff and not add them to teh spam meter if they aren't repeated constantly?

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Spam Meter
« Reply #2 on: August 13, 2007, 06:44:26 pm »
If somebody leaves and rejoins, wouldn't this reset their gmute?

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: Spam Meter
« Reply #3 on: August 13, 2007, 07:04:02 pm »
If somebody leaves and rejoins, wouldn't this reset their gmute?
There is an option to ungmute them when they leave - by default it's set to true

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Spam Meter
« Reply #4 on: August 13, 2007, 07:19:03 pm »
This is somewhat similar to how the anti-chatflood built into the server works, only it's not configurable since it was just thrown in as a basic measure. In terms of percentages, which is what this script uses, the server increases a persons meter by 12.5% everytime they say something, and decreases it by 12.5%/second. It was really only intended for stopping people spamming with taunts at a rediculous rate, which is why it isn't tailored toward slow spamming.

Offline Freedom

  • Major
  • *
  • Posts: 97
  • Veritas Vincit
Re: Spam Meter
« Reply #5 on: August 16, 2007, 08:22:46 am »
Very good & cool script!
Congratulations ;P

5 :D
Cum pare contendere anceps est, cum superiore furiosum, cum inferiore sordidum.

Offline Dr. Zombi3

  • Soldier
  • **
  • Posts: 224
  • Happy Almost Halloween :)
Re: Spam Meter
« Reply #6 on: August 16, 2007, 12:07:20 pm »
Great! Those Spammers Dont Stand A Chance!!! ***** Stars, Dr. Zombi3
3 warnings then did naughty thing. Now Banned.