0 Members and 1 Guest are viewing this topic.
const ADMIN_MLIST_ON=1; //turn off/on admin /mapslist command PLAYER_MLIST_ON=1; //turn off/on player !mapslist commandvar mapsList: TStringArray; i: integer;procedure OnCommand(ID: integer;Text: string);begin if((Text='/mapslist')and(ADMIN_MLIST_ON=1)) then begin mapsList:= split(ReadFile('mapslist.txt'),chr(13)+chr(10)); for i:=0 to ArrayHigh(mapsList)-1 do SayToPlayer(ID,mapsList[i]); end;end;procedure OnPlayerSpeak(Name,Text: string);begin if((Text='!mapslist')and(PLAYER_MLIST_ON=1)) then begin mapsList:= split(ReadFile('mapslist.txt'),chr(13)+chr(10)); for i:=0 to ArrayHigh(mapsList)-1 do SayToPlayer(NametoID(Name),mapsList[i]); end;end;
// xsplit by KeYDoNfunction xsplit(const source: string; const delimiter: string): TStringArray;var i, x, d: integer; s: string;begin d := length(delimiter); x := 0; i := 1; SetArrayLength(Result, 1); while (i <= length(source)) do begin s := Copy(source, i, d); if (s = delimiter) then begin inc(i, d); inc(x, 1); SetArrayLength(result, x + 1); end else begin result[x] := result[x] + Copy(s, 1, 1); inc(i, 1); end; end;end;function OnCommand(ID: byte; Text: string): boolean;var lines: TStringArray; i: integer;begin Result := false; if LowerCase(Text) = '/mapslist' then begin lines := xsplit(ReadFile('mapslist.txt'), chr(13) + chr(10)); for i := 0 to GetArrayLength(lines) - 1 do begin if ID <> 255 then WriteConsole(ID, lines[i], $FFFFFFFF) else WriteLn(lines[i]); end; end;end;procedure OnPlayerSpeak(ID: byte; Text: string);var lines: TStringArray; i: integer;begin if LowerCase(Text) = '!mapslist' then begin lines := xsplit(ReadFile('mapslist.txt'), chr(13) + chr(10)); for i := 0 to GetArrayLength(lines) - 1 do WriteConsole(ID, lines[i], $FFFFFFFF); end;end;