This is a bit confusing but will try best to explain it. please ask if you need more details.
First i have a class called TPlayers Like so..
TPlayers = class
Private
p : array[1..20] of TStringList;
function GetPlayer(i:integer): TStringList;
Public
Property player[i : integer] : TStringList read GetPlayer;
constructor Create; virtual;
implementation
uses
main;
{constructor}
constructor TPlayers.Create;
begin
p[1] := TStringList.Create;
p[2] := TStringList.Create;
p[3] := TStringList.Create;
p[4] := TStringList.Create;
p[5] := TStringList.Create;
p[6] := TStringList.Create;
end;
function TPlayers.GetPlayer(i: integer): TStringList;
begin
Result := p[i];
end;
I now have FTherePlayers := TPlayers.Create to create the class.
First time i add to the stringlist like so
FTherePlayers.Player[strtoint(name2)].Add('posx='+inttostr(posL.x));
or with variables taken out
FTherePlayers.Player[1].Add('posx=15');
This seems to be fine, but next i try to update it like so
FTherePlayers.Player[strtoint(ID)].Values['posx='] := xpos;
or with variables taken out
FTherePlayers.Player[1].Values['posx='] := 12;
but then i check that value after changing it and it still says 15, thus when i do
showmessage(fthereplayers.player[1].Values['posx']);
it returns 15 but it should be 12. Any idea why its not changeing? thanks Glen
FTherePlayers.Player[strtoint(ID)].Values['posx='] := xpos;, it should beFTherePlayers.Player[strtoint(ID)].Values['posx'] := xpos;instead. But it's not a good idea to expose those string lists, rather create method for adding, likeTPlayers.AddPlayerand indexed property e.g.TPlayers.PlayerPosition[x], which will access theValuesof the internal string list.