Results 1 to 4 of 4

Thread: Out of Range

  1. #1
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Out of Range

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

    SCAR Code:
    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;

  2. #2
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

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

  3. #3
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    what line is always good

  4. #4
    Join Date
    Oct 2006
    Posts
    468
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry, it's this line

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

    And I think you got it Method. Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •