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
  • Try asking for help in the chatbox
  • World Hopper (Full World)


    XZybez
     Share

    Recommended Posts

    Hi Community,

     

    i was playing around with API and was wondering how to get the World Population before i hop to a new world?
    I run into issue that my script fails in case i hop to a full world.

    Thank you in forward and stay safe.

    Link to comment
    Share on other sites

    The db api doesn't have a method to get the world population unfortunately. You will need to get the world population from the rs site. Here's a world info class I found forever ago and tweaked it a little bit to work for db.

     

    package utils;
    
    import java.io.DataInputStream;
    import java.io.IOException;
    import java.net.URL;
    import java.net.URLConnection;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.List;
    
    public class World {
        private final int id;
        private final boolean member;
        private final boolean pvp;
        private final boolean highRisk;
        private final boolean deadman;
        private final String host;
        private final String activity;
        private final int serverLoc;
        private final int playerCount;
        private final int flag;
    
        public World(int id, int flag, boolean member, boolean pvp, boolean highRisk, String host, String activity, int serverLoc, int playerCount) {
            this.id = id;
            this.flag = flag;
            this.member = member;
            this.pvp = pvp;
            this.highRisk = highRisk;
            this.host = host;
            this.activity = activity;
            this.serverLoc = serverLoc;
            this.playerCount = playerCount;
            deadman = activity.toLowerCase().contains("deadman");
        }
    
        public int getId() {
            return id;
        }
    
        public int getFlag() {
            return flag;
        }
    
        public boolean isMember() {
            return member;
        }
    
        public boolean isPvp() {
            return pvp;
        }
    
        public boolean isHighRisk() {
            return highRisk;
        }
    
        public boolean isDeadman() {
            return deadman;
        }
    
        public String getHost() {
            return host;
        }
    
        public String getActivity() {
            return activity;
        }
    
        public int getServerLoc() {
            return serverLoc;
        }
    
        public int getPlayerCount() {
            return playerCount;
        }
    
        public static List<World> load() throws IOException {
            List<World> worldList = new ArrayList<>();
            URLConnection conn = new URL("http://oldschool.runescape.com/slr").openConnection();
            try (DataInputStream dis = new DataInputStream(conn.getInputStream())) {
                int size = dis.readInt() & 0xFF;
                int worldCount = dis.readShort();
                for (int i = 0; i < worldCount; i++) {
                    int world = dis.readShort() & 0xFFFF;
                    int flag = dis.readInt();
                    boolean member = (flag & 0x1) != 0;
                    boolean pvp = (flag & 0x4) != 0;
                    boolean highRisk = (flag & 0x400) != 0;
    
                    String host = null, activity = null;
                    StringBuilder sb = new StringBuilder();
                    byte b;
                    while (true) {
                        b = dis.readByte();
                        if (b == 0) {
                            if (host == null) {
                                host = sb.toString();
                                sb = new StringBuilder();
                            } else {
                                activity = sb.toString();
                                break;
                            }
                        } else {
                            sb.append((char) b);
                        }
                    }
    
                    int serverLoc = dis.readByte() & 0xFF;
                    int playerCount = dis.readShort();
    
                    worldList.add(new World(world, flag, member, pvp, highRisk, host, activity, serverLoc, playerCount));
                }
            }
            worldList.sort(Comparator.comparingInt(World::getId));
            return Collections.unmodifiableList(worldList);
        }
    }

     

    Link to comment
    Share on other sites

    14 hours ago, XZybez said:

    Hi Community,

     

    i was playing around with API and was wondering how to get the World Population before i hop to a new world?
    I run into issue that my script fails in case i hop to a full world.

    Thank you in forward and stay safe.

    Tbh, I just filtered out worlds that tend to be full. World 2, etc, etc. There's really not that many worlds that actually get full. Probably 3-4 MAX.

    Link to comment
    Share on other sites

    Thank you for the reply's.
    Will see how i can get this data. Kinda just started to get into the osrs and dream bot API so will take a while to learn all possibility here.

    Link to comment
    Share on other sites

    • 3 weeks later...

       might not be the "best" way but it is a way to worldhop none the less....

     

     private boolean hopWorlds = false;
        private final int[] Worlds = new int[]{ 301, 302, 303 ,etc.}; //insert ALL WORLDS YOU LIKE, they do change from time to time.

    Onloop or something:

    if ( Condition ) {

                int hopTo = Worlds[Calculations.random(0,Worlds.length-1)];
                while(hopTo == getClient().getCurrentWorld())
                    hopTo = Worlds[Calculations.random(0,Worlds.length-1)];
                getWorldHopper().hopWorld(hopTo);
            } else {
                try {
                    Thread.sleep(Calculations.random(8000,15000));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

    Link to comment
    Share on other sites

    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
     Share

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