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
  • Can someone tell me what i'm messing up here?


    Samuel91
     Share

    Recommended Posts

    I'm trying to add a delay to the LoginSolver, but so far am having no luck. The below code should:

    • Detect that im logged out
    • Wait 10 seconds
    • Log in
    • Once logged in disable LoginSolver (it never gets to this part)
    • Continue with the script (in this case outputting hello world!)

    but it just keeps trying to run the login code over and over again

     

    public class Main extends AbstractScript {
    
        public void onStart() {
            getRandomManager().disableSolver(RandomEvent.LOGIN);
        }
    
        @Override
        public int onLoop() {
            if (!GameState.valueOf("LOGGED_IN").equals(true)) {
                log("got here 1 !!!!");
                //int sleepamount = Calculations.random(30, 181); // 30 seconds - 180 seconds (3 minutes)
                int sleepamount = 10;
                log("Will log in in: " + sleepamount + " seconds");
                sleep(sleepamount * 1000);
                log("starting login");
                getRandomManager().enableSolver("LOGIN");
    
            } else if (GameState.valueOf("LOGGED_IN").equals(true)) {
                log("got here 2 !!!");
                getRandomManager().disableSolver("LOGIN");
            }
    
            log("Hello, world!");
            return 3000;
        }
    }

     

    Link to comment
    Share on other sites

    I think that did it. Pseudo's suggestion did the trick.

    public class Main extends AbstractScript {
    
        public void onStart() {
            getRandomManager().disableSolver(RandomEvent.LOGIN);
        }
    
        @Override
        public int onLoop() {
            if (getClient().getGameState() != GameState.LOGGED_IN) {
                //int sleepamount = Calculations.random(30, 181); // 30 seconds - 180 seconds (3 minutes)
                int sleepamount = 10;
                log("Will log in in: " + sleepamount + " seconds");
                sleep(sleepamount * 1000);
                log("starting login");
                getRandomManager().enableSolver("LOGIN");
                getRandomManager().onLoop();
                return 0;
            }
    
            getRandomManager().disableSolver("LOGIN");
            log("Hello, world!");
            return 3000;
        }
    }

     

    Link to comment
    Share on other sites

    19 minutes ago, Samuel91 said:

    I think that did it. Pseudo's suggestion did the trick.

    public class Main extends AbstractScript {
    
        public void onStart() {
            getRandomManager().disableSolver(RandomEvent.LOGIN);
        }
    
        @Override
        public int onLoop() {
            if (getClient().getGameState() != GameState.LOGGED_IN) {
                //int sleepamount = Calculations.random(30, 181); // 30 seconds - 180 seconds (3 minutes)
                int sleepamount = 10;
                log("Will log in in: " + sleepamount + " seconds");
                sleep(sleepamount * 1000);
                log("starting login");
                getRandomManager().enableSolver("LOGIN");
                getRandomManager().onLoop();
                return 0;
            }
    
            getRandomManager().disableSolver("LOGIN");
            log("Hello, world!");
            return 3000;
        }
    }

     

    Glad to hear pal. It was more of a guess than anything, lol. Never actually tampered with the login random myself, but I had a vague recollection of using that method to check when/if I happened to be logged in.

    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.