Author Topic: TempBan Spammers  (Read 2623 times)

0 Members and 1 Guest are viewing this topic.

Offline mikembm

  • Soldier
  • **
  • Posts: 210
TempBan Spammers
« on: April 19, 2007, 08:12:32 pm »
Script Name: TempBan Spammers
Script Description: This code will allow you to punish people for spamming in your server.
For example: If somebody spams 4 times within a 2 second period then temp ban them for 2 minutes (default settings)
Original Author(s): Bmekim
Core Version: 2.5.4
Code:

Code: [Select]
const
ALLOWED_SPAM_TIMES = 4;
SPAM_TIME = 2; //in seconds
SPAM_BAN_TIME = 2; //in minutes

var
spamID,spamTimes,spamTime: integer;

function IDtoIP(PlayerID: integer):String;
begin
  case PlayerID of
    1: Result:= Player_IP_1;
    2: Result:= Player_IP_2;
    3: Result:= Player_IP_3;
    4: Result:= Player_IP_4;
    5: Result:= Player_IP_5;
    6: Result:= Player_IP_6;
    7: Result:= Player_IP_7;
    8: Result:= Player_IP_8;
    9: Result:= Player_IP_9;
    10: Result:= Player_IP_10;
    11: Result:= Player_IP_11;
    12: Result:= Player_IP_12;
    13: Result:= Player_IP_13;
    14: Result:= Player_IP_14;
    15: Result:= Player_IP_15;
    16: Result:= Player_IP_16;
    17: Result:= Player_IP_17;
    18: Result:= Player_IP_18;
    19: Result:= Player_IP_19;
    20: Result:= Player_IP_20;
    21: Result:= Player_IP_21;
    22: Result:= Player_IP_22;
    23: Result:= Player_IP_23;
    24: Result:= Player_IP_24;
    25: Result:= Player_IP_25;
    26: Result:= Player_IP_26;
    27: Result:= Player_IP_27;
    28: Result:= Player_IP_28;
    29: Result:= Player_IP_29;
    30: Result:= Player_IP_30;
    31: Result:= Player_IP_31;
    32: Result:= Player_IP_32;
  end;
end;

procedure handleSpam(ID: integer);
var
time,timeDiff: integer;
begin
time := strtoint(FormatDate('n')) * 60 + strtoint(FormatDate('s'));
if ID <> spamID then begin
spamID := ID;
spamTimes := 1;
spamTime := time;
end
else begin
spamTimes := spamTimes + 1;
timeDiff := time - spamTime;
if timeDiff < 0 then timeDiff := (3600 - spamTime + time);

if timeDiff <= SPAM_TIME then begin
if spamTimes >= ALLOWED_SPAM_TIMES then begin
SayToPlayer(ID, 'Spam Punishment: ' +inttostr(SPAM_BAN_TIME) +' Minute Ban');
Command('/tempban ' +inttostr(SPAM_BAN_TIME) +' ' +IDtoIP(ID));
Command('/kick ' +inttostr(ID));
spamID := 0;
end;
end
else begin
spamTimes := 1;
spamTime := time;
end;
end;
end;

procedure OnJoinTeam(IP, Nickname: string;Team: byte);
begin
if NameToID(Nickname) = spamID then spamID := 0;
end;

procedure OnLeaveGame(IP, Nickname: string;Team: byte);
begin
if NameToID(Nickname) = spamID then spamID := 0;
end;

procedure OnPlayerSpeak(Name,Text: string);
begin
handleSpam(NameToID(Name));
end;

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: TempBan Spammers
« Reply #1 on: April 20, 2007, 12:30:48 am »
IsnĀ“t this hard-coded into the server ?

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: TempBan Spammers
« Reply #2 on: April 20, 2007, 12:50:46 am »
Flood kicking is built in but I don't think it's customizable.
And even with the built in flood kicker a considerable amount of spam can still occur without them getting kicked.

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: TempBan Spammers
« Reply #3 on: April 20, 2007, 07:24:09 am »
you know some people spam some lines every 2 seconds... what about them? i think there should be an actual spam-o-meter, every line a player writes increases spam-o-meter by 20 percent+25% of the percentage arleady spammed, 5 percent are removed every second. 100 percent filled spam-o-meter = ban. you know what i mean?
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: TempBan Spammers
« Reply #4 on: April 20, 2007, 09:05:26 am »
Currently the way it works in the server, is a player gets 8 warnings; every time a player says something, the warning counter gets incremented, and I believe it's every second it gets decremented by 1.