Jump to content

onLoop() not called with -norandoms on some occasions


scape

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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