Jump to content

World hopping with limits


Hayase

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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