Author Topic: Bad name kick/ban script  (Read 3235 times)

0 Members and 1 Guest are viewing this topic.

Offline UpNorth.se

  • Major(1)
  • Posts: 7
Bad name kick/ban script
« on: November 26, 2006, 03:34:20 am »
Script Name: Bad names
Script Description: A script that allows you to ban or kick certain names that's in a textfile.
Original Author: UpNorth.Se
Core Version: 2.5.2

Code: [Select]
procedure OnJoinTeam(IP, Nickname: string;Team: byte);
var bNames, bType, wtf: TStringArray;
begin
bNames:= split(ReadFile('bnames.txt'),chr(13)+chr(10));
for i:=0 to ArrayHigh(bNames)-1 do begin
bType := split(bNames[i],':');

if Copy(bType[0],Length(bType[0]), 1) = '*' then begin
if Copy(LowerCase(Nickname),1,Length(bType[0])-1) = Copy(LowerCase(bType[0]),1, Length(bType[0])-1) then begin
if Copy(bType[1],1,5) = 'kick;' then begin
KickPlayer(NametoID(Nickname));
end;
if Copy(bType[1],1,3) = 'ban' then begin
wtf := split(bType[2],';');
if wtf[0] = '' then begin
wtf[0] := '0';
end;
BanPlayer(NametoID(Nickname), StrtoInt(wtf[0]));
end;
end;
end;

if Copy(bType[0],Length(bType[0]), 1) <> '*' then begin
if LowerCase(Nickname) = Copy(LowerCase(bType[0]),1, Length(bType[0])) then begin
if Copy(bType[1],1,5) = 'kick;' then begin
KickPlayer(NametoID(Nickname));
end;
if Copy(bType[1],1,3) = 'ban' then begin
wtf := split(bType[2],';');
if wtf[0] = '' then begin
wtf[0] := '0';
end;
BanPlayer(NametoID(Nickname), StrtoInt(wtf[0]));
end;
end;
end;
end;
end;


The text file (in this case bnames.txt, which have to be located in the soldatserver main directory) should look like this:


badname1:kick;                //This will kick everyone that is exactly named badname1.
badname2*:kick;               //This will kick everyone with badname2 in the beginning of his/her nick
badname3:ban:bantime;     //Bantime can be 0 (Permanent) to whatever you like, in minutes.
badname4*:ban:bantime;   //This will ban everyone with badname4 in the beginning of his/her nick

Note:
Not working with Linux servers at the moment because of the Split() function bug.
As you see Wildcards (*) are allowed.
Do not forget the ';' in the end or the script wont work (it's there so you can make comments on each row).

I've tested the script and it seems to work okey.
Let me know if you find any errors.
« Last Edit: November 26, 2006, 12:35:05 pm by UpNorth.se »

Offline cooz

  • Soldier
  • **
  • Posts: 187
  • BANNED
Re: Bad name kick/ban script
« Reply #1 on: November 26, 2006, 04:13:11 am »
really nice script,
i still have to test it,

but right now i can tell that it wont work on linux servers,
cause on bug in split() function ;)
Dead man! Dead man walking! We got a dead man walking here! Banned man crawling more like

Offline UpNorth.se

  • Major(1)
  • Posts: 7
Re: Bad name kick/ban script
« Reply #2 on: November 26, 2006, 12:24:22 pm »
Oh ye.. I read about that, hope they'll fix it soon.