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
  • sleepUntil() in onStart, trying to get localPlayer data


    Recommended Posts

    So i'm trying to get get data about the local player (I want the amount of xp they have in a skill), so I put the SkillTracker in the onStart method. However, because the player doesn't start logged in, this causes issues with initializing the SkillTracker variable. I tried putting 

    Sleep.sleepUntil(() -> Client.isLoggedIn(), 10000);

    But the login solver also does not run, because I made it sleep. 

    All that to ask, how can I get my code to wait until the program has logged in?

    Link to comment
    Share on other sites

    59 minutes ago, Doxial said:

    So i'm trying to get get data about the local player (I want the amount of xp they have in a skill), so I put the SkillTracker in the onStart method. However, because the player doesn't start logged in, this causes issues with initializing the SkillTracker variable. I tried putting 

    dont, put it in onloop and check if its not already set and you are logged in

    Link to comment
    Share on other sites

    • 2 weeks later...
    On 4/23/2024 at 5:00 PM, camelCase said:

    dont, put it in onloop and check if its not already set and you are logged in

    from my personal scripts i use this:
     

    OnStart method

            if (Client.isLoggedIn()) {
                SkillTracker.start(Skill.THIEVING);
                startingThievingExp = SkillTracker.getStartExperience(Skill.THIEVING);
            }



    Loop method

        @Override
        public int onLoop() {
            if (timer != null && timer.isPaused()) {
                timer.resume();
            }
            if (!SkillTracker.hasStarted(Skill.THIEVING)) SkillTracker.start(Skill.THIEVING);
            if(startingThievingExp == 0) startingThievingExp = SkillTracker.getStartExperience(Skill.THIEVING);
    
            if(getSettings().shouldLoop) {
                return this.getRoot().onLoop();
            }
            return 200;
        }


     

    Link to comment
    Share on other sites

    8 hours ago, ImLife said:
            if (!SkillTracker.hasStarted(Skill.THIEVING)) SkillTracker.start(Skill.THIEVING);

    you still need to check if you're logged in

    Link to comment
    Share on other sites

    • 1 month later...
    On 5/8/2024 at 6:49 PM, Luxe said:

    from my personal scripts i use this:
     

    OnStart method

            if (Client.isLoggedIn()) {
                SkillTracker.start(Skill.THIEVING);
                startingThievingExp = SkillTracker.getStartExperience(Skill.THIEVING);
            }



    Loop method

        @Override
        public int onLoop() {
            if (timer != null && timer.isPaused()) {
                timer.resume();
            }
            if (!SkillTracker.hasStarted(Skill.THIEVING)) SkillTracker.start(Skill.THIEVING);
            if(startingThievingExp == 0) startingThievingExp = SkillTracker.getStartExperience(Skill.THIEVING);
    
            if(getSettings().shouldLoop) {
                return this.getRoot().onLoop();
            }
            return 200;
        }

    Thanks for sharing, I will try it.
     

    Edit: I tried it and it works for me.

    Edited by BeatriceCox
    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
    ×
    ×
    • 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.