From: jhildy
Thanks, this is exactly what I was looking for. Now is this just limited to players on the currently loaded screen? I know I could filter them out after the fact by checking their tile position, but I am just wondering how far away this detects other players. Also, is there a field for the location of each player?
Heres with the location of the player, and it gets all the players from currently loaded region, which is 104x104.
program R_GetPlayers_TEST;
{$DEFINE SMART8}
{$I SRL-OSR/SRL.Simba}
{$I SRL-OSR/SRL/Misc/SmartGraphics.Simba}
{$I SRL-OSR/SRL/reflection/Reflection.simba}
type
TPlayer = record
Name: String;
Level: Integer;
Tile: TPoint;
end;
TPlayerArray = Array of TPlayer;
function CreatePlayer(Name: String; Level: Integer; Tile: TPoint): TPlayer;
begin
Result.Name := Name;
Result.Level := Level;
Result.Tile := Tile;
end;
function R_GetPlayers: TPlayerArray;
var
I, J, _Count, _Player, _Name, _Level, _X, _Y: Integer;
begin
_Count := SmartGetFieldArraySize(SmartCurrentTarget, 0, 'client.ga', 0);
SetLength(Result, J);
for I := 0 to _Count - 1 do begin
_Player := SmartGetFieldArrayObject(SmartCurrentTarget, 0, 'client.ga', I);
if (_Player <= 0) then
Continue;
Inc(J);
SetLength(Result, J);
_Name := SmartGetFieldObject(SmartCurrentTarget, _Player, 'e');
_Level := SmartGetFieldInt(SmartCurrentTarget, _Player, 'j') * 1106596591;
_X := (SmartGetFieldInt(SmartCurrentTarget, 0, client_baseX) * client_baseX_Multiplier) + (SmartGetFieldInt(SmartCurrentTarget, _Player, 's') * -806469611) div 128;
_Y := (SmartGetFieldInt(SmartCurrentTarget, 0, client_baseY) * client_baseY_Multiplier) + (SmartGetFieldInt(SmartCurrentTarget, _Player, 'y') * -54698801) div 128;
Result[J - 1] := CreatePlayer(R_GetJavaString(_Name, 512), _Level, Point(_X, _Y));
SmartFreeObject(SmartCurrentTarget, _Name);
SmartFreeObject(SmartCurrentTarget, _Player);
end;
end;
begin
SetupSRL;
SetupReflection;
Writeln(R_GetPlayers);
end.