R0b0t1
2008-05-14 21:13:23
If you're me, you just hate typing out or having to copy/paste and then edit the numbers or something like that.
So I made this! I am actually using it in one of my scripts, I'm sure it compiles. If I can make it better I will.
Oh, this is really good if you have forms. You'll need the array interface anyway if it doesn't have some kind of form…
If you add extra elements to an array, it just doesn't use them. If you add too few, it shows an error like the 'Missing GameTab' one. Just be smart and you won't get problems with it.
So I made this! I am actually using it in one of my scripts, I'm sure it compiles. If I can make it better I will.
Oh, this is really good if you have forms. You'll need the array interface anyway if it doesn't have some kind of form…
procedure SetPlayerSpecs(MUser, MPass, MNick, MAct, MStr, MInt, MBool, MExt: TVariantArray);
var
PlayerLoop: Integer;
UV: Array [0..4] of Boolean;
begin
NumberOfPlayers(High(MUser));
CurrentPlayer := 0;
UV[0] := (High(MStr) = -1)
UV[1] := (High(MInt) = -1)
UV[2] := (High(MBool)= -1)
UV[3] := (High(MExt) = -1)
try
for PlayerLoop := 0 to High(MUser) do
begin
Players[PlayerLoop].Name := MUser[PlayerLoop];
Players[PlayerLoop].Pass := MPass[PlayerLoop];
Players[PlayerLoop].Nick := MNick[PlayerLoop];
Players[PlayerLoop].Active := MAct[PlayerLoop];
if not UV[0] then Players[PlayerLoop].Strings[PlayerLoop] := MStr[PlayerLoop];
if not UV[1] then Players[PlayerLoop].Integers[PlayerLoop] := MInt[PlayerLoop];
if not UV[2] then Players[PlayerLoop].Booleans[PlayerLoop] := MBool[PlayerLoop];
if not UV[3] then Players[PlayerLoop].Extendeds[PlayerLoop] := MExt[PlayerLoop];
end;
except
srl_Warn('SetPlayerSpecs', 'Array indexing error (check input values)', -1);
end;
end;
If you add extra elements to an array, it just doesn't use them. If you add too few, it shows an error like the 'Missing GameTab' one. Just be smart and you won't get problems with it.
SetPlayerSpecs([MyUser, MyUser2, ...], [MyPass, ...], [MyNick, ...], [True, ...], [MyStr, ...], [MyInt, ...], [MyBoolean, ...], [MyExtended, ...]);