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
  • Retrieving Highscores very quickly


    kamilo

    Recommended Posts

    Using this snippet, i am able to retrieve highscore of a particular player, but it takes A few seconds to process.

     

    package mainscript.utils;
    
    public enum Skills {
    
        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);
    
        Skills(int levelIndex) {
            this.levelIndex = levelIndex;
        }
       
        private int levelIndex;
    
        public int getLevelIndex() {
            return levelIndex;
        }
    }

     

    package mainscript.utils;
    
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLConnection;
    import java.util.ArrayList;
    
    public class Highscores {
       
        ArrayList<String> stats = new ArrayList<String>();
       
        public Highscores(String player) {
            getStats(player);
        }
       
        public final int getSkillLevel(Skills skill) {
            int index = skill.getLevelIndex();
            String[] array = stats.get(index).split(",");
            return Integer.parseInt(array[1]);
        }
       
        public final int getSkillExperience(Skills skill) {
            int index = skill.getLevelIndex();
            String[] array = stats.get(index).split(",");
            return Integer.parseInt(array[2]);
        }
    
        private void getStats(final String player) {
            try {
                URL url = new URL("https://secure.runescape.com/m=hiscore_oldschool/index_lite.ws?player=" + player);
                URLConnection con = url.openConnection();
                BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    
                String inputLine;
                while ((inputLine = in.readLine()) != null) {
                    stats.add(inputLine);
                }
                in.close();
            } catch (MalformedURLException e) {
                //CATCH
            } catch (IOException e) {
                //CATCH
            }
        }
    }

     

    Wondering if there's a quicker method to resolve this? I understand that getting information from a webpage may take a while but this poses me some problem

    if i was to filter out a list of players around me with magic levels of 85 or higher, it would take quite a while to retrieve the stats since each lookup would take a couple of seconds

    and this would be a problem if theres 5-20 people around me

     

    Please let me know if this it the limit and there's no way to speed it up 

    Link to comment
    Share on other sites

    Wondering if there's a quicker method to resolve this? I understand that getting information from a webpage may take a while but this poses me some problem

    if i was to filter out a list of players around me with magic levels of 85 or higher, it would take quite a while to retrieve the stats since each lookup would take a couple of seconds

    and this would be a problem if theres 5-20 people around me

     

    Please let me know if this it the limit and there's no way to speed it up 

    Link to comment
    Share on other sites

    This is the model way of doing it, as you need to go on the website and fetch the data, it has to take a few seconds to fetch the data from the website as it depends on the response time from jagex.

    Link to comment
    Share on other sites

    6 hours ago, Defiled said:

    This is the model way of doing it, as you need to go on the website and fetch the data, it has to take a few seconds to fetch the data from the website as it depends on the response time from jagex.

    i see so basically the retrievel of data time is the lowest time ill get?

    Link to comment
    Share on other sites

    8 minutes ago, kamilo said:

    i see so basically the retrievel of data time is the lowest time ill get?

    It basically depends on the response time of runescape's website, the only way to speed it up is to contact Jagex lol

    Link to comment
    Share on other sites

    You could always parallelize the work. It would make things take much less time if you get more and more players near you.

    For instance:
    "if i was to filter out a list of players around me with magic levels of 85 or higher, it would take quite a while to retrieve the stats since each lookup would take a couple of seconds "

    Java makes it quite easy to achieve this:

    List<Player> players = getPlayers().all();
    if(players != null && players.size() > 0) {
          List<Player> filtered = players.parallelStream().filter(p != null && p.exists() && (new Highscores(p).getSkillLevel(Skills.MAGIC) >= 85)).collect(Collectors.toList());
    }


    Granted it still takes time but I'm pretty sure you can notice the difference if you try
     

    Link to comment
    Share on other sites

    5 minutes ago, Neffarion said:

    You could always parallelize the work. It would make things take much less time if you get more and more players near you.

    For instance:
    "if i was to filter out a list of players around me with magic levels of 85 or higher, it would take quite a while to retrieve the stats since each lookup would take a couple of seconds "

    Java makes it quite easy to achieve this:

    
    List<Player> players = getPlayers().all();
    if(players != null && players.size() > 0) {
          List<Player> filtered = players.parallelStream().filter(p != null && p.exists() && (new Highscores(p).getSkillLevel(Skills.MAGIC) >= 85)).collect(Collectors.toList());
    }


    Granted it still takes time but I'm pretty sure you can notice the difference if you try
     

    Thanks ill give this a try!!

    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.