Jump to content

How to suppreess LoginEvent and inventory listener question


Recommended Posts

Posted

Hi there guys. So today I stumbled upon these two things when writing a script.

 

First I have problem with keeping track of how many things I have gathered. I have tried many ways of doing it, even went here for help and found this post http://osbot.org/forum/topic/75766-inventorymonitor-snippet/?hl=thread which worked pretty well, but every time I hopped world, the last ammount added, was added again. So say I had 10 items in inventory, I gathered another 5 (15 now) and when I hopped world the counter went to 20. So how should a basic thread based inventory listener look like - which will work with world hopping?

 

Another thing that I found problematic was the world hopping limit - after some ammount of worlds hopped in fast succession it will log you out. So I would like to make it so my script will sleep for like 5 mins when this happens and after that comes back. How could I suppress LoginEvent when I get logged out and then use it again after some time?

 

If someone can help me with those two things, please post ahead, I would appreciate it :)

Posted

Why is it adding another five when you hop worlds?

Why does your solution involve adding an inventory listener; are you aware of the consequences (good and bad) of using one?

 

I think I have used the wrong term. I need InventoryMonitor - which will count how many items I've gathered. The one I linked in the post works fine, but I had to add a check for when I'm banking, because it worked both ways: adding and substracting aswell. But that was easy. And I don't know why it increments the counter variable when hopping worlds.

Posted

@Flamezzz How would I then register auto_login back again? registerHook() and registerRandoms() is not working with RandomEvent.AUTO_LOGIN...

 

let me help you out.

 

create your own random solver http://osbot.org/api/org/osbot/rs07/script/RandomSolver.html with out script manifest

then you would get the random executor from the bot class.

use the method Bot#registerRandoms(arg) (add your random solver as the arg)

finally remove the login random by unregister it

 

the reason why you still have to remove it because registerRandoms()

the method above

Reloads all random solvers and registers third party randoms designed for particular scripts.

WITHDRAW_NOTE: The third part random solvers specified here should not have a @link ScriptManifest attribute!

Posted (edited)

 

let me help you out.

 

create your own random solver http://osbot.org/api/org/osbot/rs07/script/RandomSolver.html with out script manifest

then you would get the random executor from the bot class.

use the method Bot#registerRandoms(arg) (add your random solver as the arg)

finally remove the login random by unregister it

 

the reason why you still have to remove it because registerRandoms()

 

 

Thanks man, I've already done this in my onStart() and it seems to be working...

bot.getRandomExecutor().unregisterHook(RandomEvent.AUTO_LOGIN);
bot.getRandomExecutor().registerHook(new RandomBehaviourHook(RandomEvent.AUTO_LOGIN) {
	@Override
	public void onStart() throws InterruptedException{
		mouse.moveOutsideScreen();
		sleep(random(180000,240000));
	}
});
Edited by blabla123
  • Like 1
Posted

 

Thanks man, I've already done this in my onStart() and it seems to be working...

bot.getRandomExecutor().unregisterHook(RandomEvent.AUTO_LOGIN);
bot.getRandomExecutor().registerHook(new RandomBehaviourHook(RandomEvent.AUTO_LOGIN) {
	@Override
	public void onStart() throws InterruptedException{
		mouse.moveOutsideScreen();
		sleep(random(180000,240000));
	}
});

nice i never really played with these hooks but nice to hear back that you got it to work.

  • Like 1

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