Author Topic: [Remake] Blacklist (Bad names)  (Read 2412 times)

0 Members and 1 Guest are viewing this topic.

Offline KeYDoN

  • Major
  • *
  • Posts: 60
[Remake] Blacklist (Bad names)
« on: May 05, 2007, 08:12:49 pm »
Script Name: Blacklist
Script Description: A script that allows you to ban or kick certain names that's in a textfile.
Original Author(s): UpNorth.Se
Core Version: 1.0.0 (ServerVersion: 2.6.1)
Requirements: xspilt

I added the possibility to administrate the blacklist ingame/adminconsole and ported it to new version
Code:
Code: [Select]
var
  bnames: TStringArray;
 
procedure SayToID(Const ID:integer;const Text:String);
begin
if (ID=255) then WriteLn(Text)
else SayToPlayer(ID,Text);
end;

procedure ActivateServer();
begin
bNames:= xsplit(ReadFile('bnames.txt'),chr(13)+chr(10));
if(bNames[ArrayHigh(bNames)]='') then SetArrayLength(bNames,ArrayHigh(bNames));
end;

procedure AddBadName(const ID: Byte;const Pattern: String; const Ban: Boolean);
var
Parts: TStringArray;
m,i: integer;
S:String;
begin
if Ban then begin
Parts:= xsplit(Pattern,':');
try
m:= StrToInt(Parts[ArrayHigh(Parts)]);
except
m:=0;
end;
s:= Parts[0];
for i:=1 to ArrayHigh(Parts)-1 do Begin
s:= s +':'+ Parts[i];
end;
s:= s + ':ban:' + IntToStr(m)+ ';';
end else begin
s:= Pattern+':kick;';
end;
WriteLnFile('bnames.txt',s);
SetArrayLength(bNames,ArrayHigh(bNames)+2);
bNames[ArrayHigh(bNames)]:= s;
SayToID(ID,'Line >'+s+ '< added');
end;

procedure DelBadName(const ID: Byte;const Pattern: String);
var
i,z:integer;
s:string;
found: Boolean;
begin
z:= Length(Pattern)+1;
  for i:=0 to ArrayHigh(bNames) do begin
  if (LowerCase(Copy(bNames[i],1,z))=LowerCase(Pattern)+':') then begin
  for z:=i to ArrayHigh(bNames)-1 do begin
  bnames[z]:= bnames[z+1];
  end;
  SetArrayLength(bNames,ArrayHigh(bNames));
  Found:= true;
  end;
  end
  if Found then begin
  for i:=0 to ArrayHigh(bnames) do begin
s:=s+bnames[i]+chr(13)+chr(10);
end;
WriteFile('bnames.txt',s);
SayToID(ID,Pattern+' deleted');
end else SayToID(ID,Pattern+ ' not found');
end;

function OnCommand(ID: Byte; Text: string): boolean;
begin
  if (Copy(Text,1,11) = '/addbadname') then begin
  if (Copy(Text,12,1)= 'b') then AddBadName(ID,Copy(Text,14,21),True)
  else AddBadName(ID,Copy(Text,13,16),False);
  end;
  if (Copy(Text,1,11) = '/delbadname') then DelBadName(ID,Copy(Text,13,16));
end;

procedure CheckBadName(ID:Byte);
var
bType, wtf: TStringArray;
i:integer;
Nickname: String;
begin
Nickname:= LowerCase(IDtoName(ID));
for i:=0 to ArrayHigh(bNames) do begin
SetArrayLength(bType,0);
bType := xsplit(bNames[i],':');

if MaskCheck(Nickname,bType[0]) then begin
if Copy(bType[1],1,5) = 'kick;' then begin
KickPlayer(ID);
end;
if Copy(bType[1],1,3) = 'ban' then begin
wtf := xsplit(bType[2],';');
if wtf[0] = '' then begin
wtf[0] := '0';
end;
BanPlayer(ID, StrtoInt(wtf[0]));
end;
end;
end;
end;

procedure OnJoinGame(ID, Team: byte);
begin
ThreadFunc([ID],'CheckBadName');
end;


Use: /addbadname NICK
to get NICK allways Kicked.
Use: /addbadnameb NICK
to ban NICK permanently
Use: /addbadnameb NICK:X
to ban NICK always when he joins for X minutes

use: /delbadname NICK
to delete the definition :)
« Last Edit: June 10, 2007, 11:01:05 am by KeYDoN »

Offline HEX

  • Major
  • *
  • Posts: 77
  • =tNt=
    • SoldatX Brazilian Community
Re: [Remake] Blacklist (Bad names)
« Reply #1 on: May 05, 2007, 09:00:52 pm »
Sweet! I'm using it.
+1 karma, thanks.