Solved Check if player is in range to see other player

Discussion in 'Plugin Development' started by unv_annihlator, Oct 15, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    unv_annihlator

    Before someone mentions it the .canSee(Player) method doesn't work, marks them as unable to see them when they are within render distance.

    Anyways, I need to find out an efficient way to find all players within rendering distance of another player. That way when I pass updates it doesn't have to update the whole player base.

    I've considered using the nearby entities method then going through that, however it's not really stated what the view distance to render a player is and I want this to be as efficient as possible. Yes I know I could spend hours on end lowering the area to check until I was right at the border, but just wondering if there was a different way of achieving what I want, or if there is a known limit for rendering.

    Any help is appreciated,
    -unv
     
  2. Offline

    Comphenix

    unv_annihlator likes this.
  3. Offline

    unv_annihlator

    Okay, so I have a player already in range of another player... then lets say on an event I need to grab all players within range of another player. How would I do that through the API of your code? All I see are the Load and Unload events. Would I just have to create a way of tacking all players who come in range and leave range for a player?
     
  4. Offline

    Comphenix

    Create a new list per player. Then on Load you simply add the loaded entity to the player's list, provided the entity is a player, and remove it again on Unload.

    These lists will then always contain every nearby player.
     
  5. Offline

    unv_annihlator

    Yea okay, that's what I figured I'd have to do. Thank you for your help.
     
    Comphenix likes this.
Thread Status:
Not open for further replies.

Share This Page