Function Name: Table
Script Description: Writes a table to a player's console, being aligned correctly
Original Author: Curt
Core Version: 2.6.3
Code:
procedure Table(const Id: byte; const TDA: array of array of string; const Color: longint);
var
i, j: word;
Echo: string;
Longest: array of word;
begin
if (GetArrayLength(TDA) = 0) then exit;
for i := 0 to GetArrayLength(TDA) - 1 do if (GetArrayLength(TDA[i]) > j) then j := GetArrayLength(TDA[i]);
SetArrayLength(Longest, j);
for i := 0 to GetArrayLength(TDA) - 1 do if (GetArrayLength(TDA[i]) > 0) then for j := 0 to GetArrayLength(TDA[i]) - 1 do if (Length(TDA[i][j]) > Longest[j]) then Longest[j] := Length(TDA[i][j]);
for i := 0 to GetArrayLength(TDA) - 1 do begin
Echo := '';
if (GetArrayLength(TDA[i]) = 0) then continue;
for j := 0 to GetArrayLength(TDA[i]) - 1 do if (GetArrayLength(TDA[i]) > 0) then begin
Echo := Echo + TDA[i][j];
if (j <> GetArrayLength(TDA[i]) - 1) then Echo := Echo + Replicate(' ', Longest[j] - Length(TDA[i][j]) + 1);
end;
WriteConsole(Id, Echo, Color);
end;
end;
Note that this is a snippet of code meant for scripters, not server owners