Jump to content

World hopping with limits


Recommended Posts

Posted (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 by Hayase
  • Like 1
Posted

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 

  • Like 1
Posted
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.

Posted
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(); }

 

  • 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...