Jump to content

player in an area or not


dokato

Recommended Posts

Is it possible to determin wether ANOTHER player (someone you dont know the name of) is in a certain area with like a boolean? (for example the area where u are in). Is there a method for that or do u have to create something urself?

 

for example:

 

final Area YOUR_AREA = new Area(bla,bla,bla,bla);

 

if(YOUR_AREA.contains(/*a player*/)){

       //...

}

 

 

Edited by dokato
Link to comment
Share on other sites

Is it possible to determin wether another player is in a certain area with like a boolean? (for example the area where u are in). Is there a method for that or do u have to create something urself?

 

for example:

 

final Area YOUR_AREA = new Area(bla,bla,bla,bla);

 

if(YOUR_AREA.contains(/*a player*/)){

       //...

}

yes you can

Link to comment
Share on other sites

Player otherPlayer = getPlayers().closest("OtherPlayerName");

 

if(YOUR_AREA.contains(otherPlayer.getPosition()) {

    //Interesting things happen

}

 

EDIT:

 

to get a list of players in your area, you can do:

 

List<Player> playersInArea = getPlayers().filter(new AreaFilter<Player>(YOUR_AREA));

Edited by FrostBug
  • Like 2
Link to comment
Share on other sites

fuck Obama

But i can't, plz tell me how then

spoonfeed me a bit smile.png

 

 

Player otherPlayer = getPlayers().closest("OtherPlayerName");

 

if(YOUR_AREA.contains(otherPlayer.getPosition()) {

    //Interesting things happen

}

 

EDIT:

 

to get a list of players in your area, you can do:

 

List<Player> playersInArea = getPlayers().filter(new AreaFilter<Player>(YOUR_AREA));

what Frostbug said ^_^ i forgot to post code lmao xD

  • Like 1
Link to comment
Share on other sites

Ow sry my bad, 

i meant if that player is a random player who u dont know the name of, but just happens to be in that area. What to do then?

 like frostbug said:

 

List<Player> playersInArea = getPlayers().filter(new AreaFilter<Player>(YOUR_AREA));

 

this will return a list of all the players in the area.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...