Jump to content

Grabbing all the local players.


Daviyow

Recommended Posts

Hey im trying to hop as soon as there is another person in my local area.. i got this but it counts myself in too, i dont know what to do its been a while >smile.png

    public void checkforPlayers() throws InterruptedException {
        List<Player> playerss = players.getAll();
        for (Player p : playerss) {
                size++;
            
        }
            if (size >= 1) {
              log("Some dude was nearby.. hopping!");
                     worldHopper.hop(WORLDS[MethodProvider.random(WORLDS.length)]);
                state = "WORLDHOP";
                size = 0;
           
        }
    }
Edited by Daviyow
Link to comment
Share on other sites

 

Hey im trying to hop as soon as there is another person in my local area.. i got this but it counts myself in too, i dont know what to do its been a while >smile.png

    public void checkforPlayers() throws InterruptedException {
        List<Player> playerss = players.getAll();
        for (Player p : playerss) {
                size++;
            
        }
            if (size > 1) {
              log("Some dude was nearby.. hopping!");
                     worldHopper.hop(WORLDS[MethodProvider.random(WORLDS.length)]);
                state = "WORLDHOP";
                size = 0;
           
        }
    }

XD if it counts you then just make it activate if there is more than one person (e.g. yourself in the area)? :P Unsure if you're asking for more but that should work fine.

Link to comment
Share on other sites

depending on how you want to do this. Because the method above only applys for people within the same region. Why am i saying this? For my safe cracker i dont want to use a method to see how many people are near the safe. If i use the method above it usually return true. Because youll have people near rouge cooking food or something.

 

So you could make a area and check to see how many people there is.

 

not too sure how you want to make the area but heads up there myPlayer#getArea(raidus).

	public boolean imAlone()	{
		Area area = null;//create your own area
		int amount = 0;
		
		for (Player player: players.getAll())	{
			if (player != null && !player.getName().equalsIgnoreCase(myPlayer().getName())){
				if (area.contains(player))	{
					amount++;
				}
			}
		}
		return amount == 0;	
	}
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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