Daviyow Posted January 18, 2015 Share Posted January 18, 2015 (edited) 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 > 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 January 18, 2015 by Daviyow Link to comment Share on other sites More sharing options...
Roar Posted January 18, 2015 Share Posted January 18, 2015 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 > 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 More sharing options...
pitoluwa Posted January 18, 2015 Share Posted January 18, 2015 why not playerss.size; or playerss.length? (i dont remember now lol) Link to comment Share on other sites More sharing options...
Botre Posted January 18, 2015 Share Posted January 18, 2015 (edited) public boolean isMyPlayerAlone(){ return getPlayers().getAll().size() <= 1; } Edited January 18, 2015 by Botre 2 Link to comment Share on other sites More sharing options...
Novak Posted January 18, 2015 Share Posted January 18, 2015 public boolean amIForeverAlone(){ return getPlayers().getAll().size() <= 1; } fixed for you 4 Link to comment Share on other sites More sharing options...
Swizzbeat Posted January 18, 2015 Share Posted January 18, 2015 Or just make sure the players accessor isn't equal to your own... Link to comment Share on other sites More sharing options...
Brown Posted January 21, 2015 Share Posted January 21, 2015 Try checking if players name matches your username. Something like: if(!p.getName().equals(myPlayer().getName())) Link to comment Share on other sites More sharing options...
Joseph Posted January 21, 2015 Share Posted January 21, 2015 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 More sharing options...