Jump to content

player in an area or not


Recommended Posts

Posted (edited)

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
Posted

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

Posted (edited)

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
Posted

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
Posted

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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