Author Topic: AdminTools  (Read 2420 times)

0 Members and 2 Guests are viewing this topic.

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
AdminTools
« on: August 19, 2010, 04:56:36 pm »
Script Name: AdminTools 2.0, BanHammer, PlayerDB (why multiple? see below)
Script Description: Tools that any admin may require on his server
Original Author(s): Falcon (me)
Used function(s): Explode() by DorkeyDear & CurryWurst
Core Version:2.6.5
Code: (example)
Code: [Select]
function OnCommand(ID: byte; Text:string): boolean;
var
ID2: byte;
time: integer;
Piece, IP, Reason: string;
again: boolean;
X, Y: single;
SlapNum: word;
begin
Result := false;
case LowerCase(GetPiece(Text, ' ', 0)) of
BanCmd: try
Result := true;
//get time
delete(Text, 1, Length(BanCmd)+1);
time := 0;
Piece := GetPiece(Text, ' ', 0);
while RegExpMatch('([0-9])+([dhm])', Piece)  do begin
if RegExpMatch('d', Piece) then time := time + StrToInt(RegExpReplace('d', Piece, '', false))*1440
else if RegExpMatch('h', Piece) then time := time + StrToInt(RegExpReplace('h', Piece, '', false))*60
else if RegExpMatch('m', Piece) then time := time + StrToInt(RegExpReplace('m', Piece, '', false));
delete(Text, 1, Length(Piece)+1);
Piece := GetPiece(Text, ' ', 0);
end;
//get IP
if RegExpMatch('\.', Piece) then begin
IP := Piece;
ID2 := 0;
end else begin
ID2 := StrToInt(Piece);
IP := IDToIP(ID2);
end;
//get reason (if any)
delete(Text, 1, Length(Piece)+1);
Reason := Text;
//process ban
if IP <> '' then begin
if (Piece <> '') AND (Piece <> IDToName(ID2)) then begin
WriteMessage(ID, 'WARNING!!! Following players found in selected ban range:', $FFFF4444);
WriteMessage(ID, Piece, $FFFFFFFF);
end;
WriteLn('Banned '+iif(ID2 > 0, IDToName(ID2)+', ', '')+'IP: '+IP+iif(Reason <> '', ' with reason: '+Reason, '')+' for '+IntToStr(time)+' minutes.');
AddBan(iif(ID2 > 0, IDToName(ID2), ''), IP, Reason, time)
if ID2 > 0 then KickPlayer(ID2);
end else WriteMessage(ID, 'Wrong IP/ID', $FFFF4444);
except
WriteMessage(ID, BanCmd+' <length> <ID or IP> <Reason>', $FFFF4444);
end;

Scripts provides commands that any admin my requre on his server. Why multiple scripts? I've decided to provide it in two versions: 3 seperate scripts and one big, with all 3 merged together. It's up to you what you download!. Little overview:

BanHammer:
This script provides extended banning system. Now you can define a ban without recounting it to minutes, buy typing for instance /banhammer 1d 4h 127.0.*.*. BanHammer provides not only extended syntax, but also extended banning system. What does it means? It bans by both IP and NICK, so that if there's some big-range player and he doesn't know that you keep big tools on your servers, he won't enter anyway. short example (cooperates with PlayerDB, explained below):
Code: [Select]
(23:34:55) /banhammer 1d 127.0.0.1 (127.0.0.1)
(23:34:55) WARNING!!! Following players found in selected ban range:
(23:34:56) (SP) Falcon (127.0.0.1)
(23:34:56) Banned IP: 127.0.0.1 for 1440 minutes.
(23:35:00) /showbans all (127.0.0.1)
(23:35:00) Unknown:
(23:35:01)     IP: 127.0.0.1
(23:35:01)     Time: 1440 minutes left
(23:35:04) /hunbanip 127.0.0.1 (127.0.0.1)
(23:35:04) IP: 127.0.0.1: unbanned
(23:35:10) /showbans ip (127.0.0.1)
(23:35:10) No bans found
(23:35:24) /banhammer 1d 1 Just for testing... (127.0.0.1)
(23:35:24) Banned (SP) Falcon, IP: 127.0.0.1 with reason: Just for testing... for 1440 minutes.
(23:35:24) (SP) Falcon has been kicked. (127.0.0.1)
(23:35:29) /showbans all (127.0.0.1)
(23:35:29) (SP) Falcon:
(23:35:29)     IP: 127.0.0.1
(23:35:29)     Time: 1440 minutes left
(23:35:29)     Reason: Just for testing...
(23:35:44) /hunbanname (SP) Falcon (127.0.0.1)
(23:35:44) (SP) Falcon, IP: 127.0.0.1 (Just for testing...): unbanned
(23:35:50) /showbans all (127.0.0.1)
(23:35:50) No bans found

OK great, it provides new syntax, bans by nick... so it's ideal? Of course it's not. There are two negative effects of using this script:

  • it doesn't show to "victim" how long ban stays. When he/she tries to join, it just writes "You have been banned from that server"
  • When ip change and it rebans by nick, player is able to join a server just for a second, so that he/she can see that there's something wrong with this ban. No info, though. At all. It just adds new ip to ban definitions and kicks that fu***r

PlayerDB:
Script is similar to this one: it provides /whois admin only command that shows all nicks and IPs used by specified player. It's not that helpful alone, but it can cooperate with BanHammer, so that if you ban a range in which are players, you're warned about that. Anyway, released as separate script. If you want those two to cooperate not as merged script (the lowest one), download both and configure them to do so (not some hard job, don't worry ;) )

Admin Tools (part):
It provides some commands that may help you teaching your players behavior, such as /strike/selfpunish. Also it provides some "hax" commands like /fw (force weapon) or /gb (give bonus).

Admin Tools (merged):
Provides all features that i wrote up there, but it's only one big fat script. If you want them all, better download this than all 3 separately

All scripts are configurable from the inside, i don't like any settings.ini so, all config options are inside as constans. If you're a "script noob" don't worry to open it too, even in notepad. It won't hurt you, i promise.

There may be one more question: Why 2.0? Here's the first version. I wrote it long time ago, and this one i've completely rewritten, so i decided to make it 2.0, not some 1.5 or similar

And one more thing before you start enjoying it: I didn't test this script(s) in "normal" enviroment, only on my empty local server, so there may be bugs that i didn't notice. If something like that happen, please report it here, or on #soldat.devs @ QuakeNet

Now Enjoy!
« Last Edit: August 20, 2010, 09:12:38 am by FalconPL »
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.