0 Members and 1 Guest are viewing this topic.
Just a short one, searching for string in mapslist and displays matches.Requested script.
const Color = $FFFF0000; file = 'mapslist.txt'; function Explode(Source: string; const Delimiter: string): array of string;var Position, DelLength, ResLength: integer;begin DelLength := Length(Delimiter); Source := Source + Delimiter; repeat Position := Pos(Delimiter, Source); SetArrayLength(Result, ResLength + 1); Result[ResLength] := Copy(Source, 1, Position - 1); ResLength := ResLength + 1; Delete(Source, 1, Position + DelLength - 1); until (Position = 0); SetArrayLength(Result, ResLength - 1);end;procedure Search(ID : byte; Text : string);var i : integer; list : array of string;begin if FileExists(file) = true then begin list := Explode(ReadFile(file), chr(13) + chr(10)); for i := 0 to ArrayHigh(list) - 1 do if ContainsString(LowerCase(list[i]), Text) then WriteConsole(ID, list[i], Color); end else WriteConsole(ID, 'File with mapslist does not exist', Color); end;function OnPlayerCommand(ID: Byte; Text: string): boolean;begin if LowerCase(Copy(Text, 1, 8)) = '/search ' then begin Delete(Text, 1, 8); Search(ID, LowerCase(Text)); end; Result := false;end;
if Copy(Text, 1, 7) = '/search' then begin
if LowerCase(Copy(Text, 1, 8)) = '/search ' then begin
Edit2: Added LowerCase to the Copy function too.