Hayase Posted February 3, 2017 Share Posted February 3, 2017 (edited) Sometimes when mining or woodcutting you might notice a ton of people just bombing your spot. Instead of losing out on gp/hr hop worlds! First we need these imports import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.Player; Now a function to detect local players and check if we should hop /** * Check if the current players in our area meets the limit * * @param area the area that the players will be calculated * @param playerLim the amount of players needed to perform a hop * @return true if the player count meets the limit */ private boolean shouldWeHop(Area area, int playerLim) { int playersInArea = 0; List<Player> nearbyPlayers = players.getAll(); //Remove our player from the list nearbyPlayers.remove(myPlayer()); for (Player player : nearbyPlayers) { if (area.contains(player)) { playersInArea++; } } return playersInArea >= playerLim; } Usage: int playerDetectionRadius = 5; //A radius of 5 steps is 5 steps in every direction from our player int playerLim = 3; //amount of players we should have before hopping if(shouldWeHop(myPlayer().getArea(playerDetectionRadius), playerLim)) { //true we should hop, let's hop! worlds.hopToF2PWorld(); } Edited February 4, 2017 by Hayase 1 Quote Link to comment Share on other sites More sharing options...
Lewis Posted February 3, 2017 Share Posted February 3, 2017 or you can do: if (getPlayers().getAll().size() > 2) { worlds.hopToF2PWorld(); } note, 2 will mean if there is 1 player or more near you as it will return 1 for your own player 1 Quote Link to comment Share on other sites More sharing options...
Juggles Posted February 3, 2017 Share Posted February 3, 2017 I've been using this a lot in my scripts and it seems to help counter bans. I find an isolated mining/woodcutting spot and put this in the code and it has lead to me not getting banned. You can also detect if anyone says part of your name/whole name and then world hop. They cant report you once you've hopped I believe 1 Quote Link to comment Share on other sites More sharing options...
Hayase Posted February 3, 2017 Author Share Posted February 3, 2017 4 minutes ago, Lewis said: or you can do: if (getPlayers().getAll().size() > 2) { worlds.hopToF2PWorld(); } note, 2 will mean if there is 1 player or more near you as it will return 1 for your own player Yes that does work, except it is too greedy when detecting nearby players. Sometimes when mining inside the dwarven mines the nearby players could pickup people that aren't even nearby. So to be more accurate with the nearby players--we count the players inside our players radius. Quote Link to comment Share on other sites More sharing options...
Stimpack Posted February 3, 2017 Share Posted February 3, 2017 6 minutes ago, Lewis said: or you can do: if (getPlayers().getAll().size() > 2) { worlds.hopToF2PWorld(); } note, 2 will mean if there is 1 player or more near you as it will return 1 for your own player shouldn't that be >= 2 or > 1? will be useful but what is playersInArea? 20 minutes ago, Hayase said: int playerDetectionRadius = 5; //A radius of 5 steps is 5 steps in every direction from our player int playerLim = 3; //amount of players we should have before hopping if(shouldWeHop(playersInArea(myPlayer().getArea(playerDetectionRadius)), playerLim)) { //true we should hop, let's hop! worlds.hopToF2PWorld(); } 1 Quote Link to comment Share on other sites More sharing options...
Lewis Posted February 3, 2017 Share Posted February 3, 2017 2 minutes ago, Stimpack said: shouldn't that be >= 2 or > 1? yeah, just using as an example. wrote it in 5 seconds lol i personally use > 1; Quote Link to comment Share on other sites More sharing options...
Team Cape Posted February 3, 2017 Share Posted February 3, 2017 public boolean shouldHop() { return getPlayers().filter(p -> p != null && myPlayer().getArea(5).contains(p)).size() > 1; } 2 Quote Link to comment Share on other sites More sharing options...
THS Posted February 4, 2017 Share Posted February 4, 2017 Might snap some of this shit up. Shot breathers. Quote Link to comment Share on other sites More sharing options...
Hayase Posted February 4, 2017 Author Share Posted February 4, 2017 5 hours ago, Stimpack said: shouldn't that be >= 2 or > 1? will be useful but what is playersInArea? oops, totally fucked up my own copy pasta 1 Quote Link to comment Share on other sites More sharing options...
TheWind Posted February 5, 2017 Share Posted February 5, 2017 A better implementation of something I already use. Thanks for this Quote Link to comment Share on other sites More sharing options...