0 Members and 1 Guest are viewing this topic.
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;