Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • world hopping


    dirtrider478

    Recommended Posts

    Im trying to get my script to save the current world that it logs into and cant quite figure it out. I know how to find out which world its currently in but dont know how to save it to come back and use that world number when trying to return to that world.

    Link to comment
    Share on other sites

    //Specific World
    public static final int HOUSE_PARTY_WORLD = 330;
    ctx.getWorldHopper().hopWorld(LocalConstants.HOUSE_PARTY_WORLD);
    
    //Random world (with lambda filter)
    world = ctx.getWorlds().getRandomWorld((w) -> !w.isF2P() && !w.isPVP() && !w.isDeadmanMode() && !w.isHighRisk());
    ctx.getWorldHopper().hopWorld(world);

     

    Id also reccomend adding a catch in your loop to wait until the hop is complete:

    
            if (getClient().getGameState() == GameState.HOPPING) {
                log("Hopping worlds");
                return 600;
            }

     

    Link to comment
    Share on other sites

    What @thecloakdone said is what you want. I would just add a few more world checks such as

    !w.isBountyWorld() && !w.isTournamentWorld() && !w.isTwistedLeague()

    You can also use

    !(w.getMinimumLevel() >= 1250)

    To disable skill-total worlds (reduce to 250 if you're using F2P). Another option is working out the player's total level and only allowing worlds that have a total level requirement less than or equal to it.

     

    From your post it seems maybe you want to get your current world if a certain condition is met, and go back to it later in the script. To do this simply save your current world in a variable and hop to it directly later:

    // Saved world object
    private World savedWorld = null;
    
    // Save the current world if some condition is met
    // For example you just saw a dragon impling in it
    if (currentWorldHasDragonImpling()) {
    	savedWorld = getWorlds().getMyWorld();
    }
    ...
    // Later in the script...
    // We've stored the world that we hopped to earlier and want to go back to later on
    if (savedWorld != null) {
    	getWorldHopper().hopWorld(savedWorld);
    }

     

     

    Link to comment
    Share on other sites

    5 hours ago, Succulent said:

    What @thecloakdone said is what you want. I would just add a few more world checks such as

    
    !w.isBountyWorld() && !w.isTournamentWorld() && !w.isTwistedLeague()

    You can also use

    
    !(w.getMinimumLevel() >= 1250)

    To disable skill-total worlds (reduce to 250 if you're using F2P). Another option is working out the player's total level and only allowing worlds that have a total level requirement less than or equal to it.

     

    From your post it seems maybe you want to get your current world if a certain condition is met, and go back to it later in the script. To do this simply save your current world in a variable and hop to it directly later:

    
    // Saved world object
    private World savedWorld = null;
    
    // Save the current world if some condition is met
    // For example you just saw a dragon impling in it
    if (currentWorldHasDragonImpling()) {
    	savedWorld = getWorlds().getMyWorld();
    }
    ...
    // Later in the script...
    // We've stored the world that we hopped to earlier and want to go back to later on
    if (savedWorld != null) {
    	getWorldHopper().hopWorld(savedWorld);
    }

     

     

     

    6 hours ago, thecloakdone said:
    
    //Specific World
    public static final int HOUSE_PARTY_WORLD = 330;
    ctx.getWorldHopper().hopWorld(LocalConstants.HOUSE_PARTY_WORLD);
    
    //Random world (with lambda filter)
    world = ctx.getWorlds().getRandomWorld((w) -> !w.isF2P() && !w.isPVP() && !w.isDeadmanMode() && !w.isHighRisk());
    ctx.getWorldHopper().hopWorld(world);

     

    Id also reccomend adding a catch in your loop to wait until the hop is complete:

    
    
            if (getClient().getGameState() == GameState.HOPPING) {
                log("Hopping worlds");
                return 600;
            }

     

    Thanks guys I ended up just adding a private int and getclient getcurrent world on public void onstart. I will be using the code for checking if the client is hopping cause that will fix some of my problems.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.