Jump to content

onLoop() not called with -norandoms on some occasions


Recommended Posts

Posted

This bug only happens when I have my own login handler implemented. I start the bot with -allow norandoms. The script functions flawlessly for some time, but after a while they all hang on logout screen.

This is my onLoop method:

@Override
	public int onLoop() {

		if (this.lastLoopPrint <= 0 || System.currentTimeMillis() - this.lastLoopPrint >= 10000) {
			this.lastLoopPrint = System.currentTimeMillis();
			log("Printing in loop");
		}

		handleState(getState());
		return random(300, 800);
	}

"Printing in loop" isn't called on the bots that have hung on logout. This means that onLoop is not being called. Why would this be happening? Is this a bot bug?

Posted

Some functions like walking wait till they're finished being executed before letting the rest of your code run again, what's probably happening is that you get logged out during an operation like this and so your login handler never gets to start running again. Add break conditions to your code for when the client isn't logged in.

Posted
21 minutes ago, HeyImJamie said:

Not if there's an issue with a getState, it'll get stuck there.

 

10 minutes ago, d0zza said:

Some functions like walking wait till they're finished being executed before letting the rest of your code run again, what's probably happening is that you get logged out during an operation like this and so your login handler never gets to start running again. Add break conditions to your code for when the client isn't logged in.

I have a check in getState() that returns state LOGIN if not logged in at the very topic before anything is executed. How would I break out of an event such as web walking that would be taking too long?

Posted
1 minute ago, scape said:

 

I have a check in getState() that returns state LOGIN if not logged in at the very topic before anything is executed. How would I break out of an event such as web walking that would be taking too long?

Your check in getState() does not matter if it is not being run, like I said above. For web walking read through this guide by Team Cape 

Otherwise add !getClient().isLoggedIn() as a break condition to your conditional sleeps and wherever else you feel necessary.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...