0 Members and 2 Guests are viewing this topic.
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;
(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