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


    Samuel91

    Recommended Posts

    Posted

    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;
        }
    }

     

    Posted

    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;
        }
    }

     

    Posted
    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.

    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.