Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: cooz on November 07, 2006, 05:05:00 am

Title: joinFloodTrace
Post by: cooz on November 07, 2006, 05:05:00 am
Script Name: joinFloodTrace
Script Description: Script which will kick and ban player who joins and leaves game rapidly
Author: cooz
Core Version: 2.5.2

Code: [Select]
const
  REDUCE = 6;    //second after flooders stats are updated, higher value - bans slower
  LIMIT = 3;       //amount of game join/leaves till ban, lower value - bans faster
  BANTIME = 60; //in minutes

var
  flooderID: array[1..32] of integer;
  i: integer;

procedure ActivateServer();
begin
  for i:= 1 to 32 do flooderID[i]:=0; //are they initialized with zeros anyway?
end;

procedure OnJoinTeam(IP, Nickname: string;Team: byte);
begin
  flooderID[NameToID(Nickname)]:= flooderID[NameToID(Nickname)]+1; //where's my i++ ;p
end;

procedure AppOnIdle(Ticks: integer);
begin
  for i:=1 to 32 do begin
    if flooderID[i]>LIMIT then begin
      BanPlayer(i,BANTIME);
      flooderID[i]:=0;
    end;
  end;

  if Ticks mod (60*REDUCE) = 0 then begin
    for i:=1 to 32 do if flooderID[i]>0 then flooderID[i]:= flooderID[i]-1;
  end;
end;