SRL Archive - OSR Help

Out of Range


bbri06

2010-05-16 17:56:16

Can anyone tell me why this is giving me an out of range error?


Function NearPlayer(TP: TPoint): boolean;
var
OPlayers: TPointArray;
i: integer;
begin
OPlayers := GetMiniMapDots('player');
if(Length(OPlayers) < 1)or(TP.x < 1)or(TP.y < 1)then
begin
Result := false;
Exit;
end;
SetLength(OPlayers, High(OPlayers) + 1);
For i := 0 to High(Players) do
begin
if(Distance(TP.x, TP.y, OPlayers[i].x, OPlayers[i].y) < 15)then
begin
Result := True;
Exit;
end;
end;
end;

Method

2010-05-16 18:03:47

It looks like you're looping from 0 to the high index of Players, not OPlayers. Perhaps that's your problem?

MylesMadness

2010-05-16 18:04:08

what line is always good

bbri06

2010-05-16 18:10:32

Sorry, it's this line


if(Distance(TP.x, TP.y, OPlayers[i].x, OPlayers[i].y) < 15)then

And I think you got it Method. Thanks :)