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
  • Fetching player stats from rs highscores


    Hosfad
     Share

    Recommended Posts

    A snippet to grab player highscores from runescape 

    public class Highscores
    {
    
        ArrayList<String> stats = new ArrayList<String>();
    
        public Highscores(String playerName) {
            getPlayerStats(playerName);
        }
    
        public int getLevel(MySkills skill) {
            try {
            int index = skill.getLevelIndex();
            String[] array = stats.get(index).split(",");
           // MethodProvider.log("Stats index : "  + stats.get(index) );
    
                return Integer.parseInt(array[1]);
            }catch (Exception e){
                return 1;
            }
    
        }
    
        public int getExperience(MySkills skill) {
            int index = skill.getLevelIndex();
            String[] array = stats.get(index).split(",");
            return Integer.parseInt(array[2]);
        }
    
        private void getPlayerStats(final String playerName) {
            try {
                URL url = new URL("https://secure.runescape.com/m=hiscore_oldschool/index_lite.ws?player=" + playerName);
                URLConnection connection = url.openConnection();
                BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    
                String inputLine;
                while ((inputLine = br.readLine()) != null) {
                    stats.add(inputLine);
                }
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
       }

     

    public enum MySkills {
    
        TOTAL(0), ATTACK(1), DEFENCE(2), STRENGTH(3), HITPOINTS(4), RANGED(5), PRAYER(6), MAGIC(7),
        COOKING(8), WOODCUTTING(9), FLETCHING(10), FISHING(11), FIREMAKING(12), CRAFTING(13),
        SMITHING(14), MINING(15), HERBLORE(16), AGILITY(17), THIEVING(18), SLAYER(19),
        FARMING(20), RUNECRAFT(21), HUNTER(22), CONSTRUCTION(23);
    
        MySkills(int levelIndex) {
    
            this.levelIndex = levelIndex;
        }
    
         int levelIndex;
    
        public int getLevelIndex() {
            return levelIndex;
        }
    }
    
    Edited by Hosfad
    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.