Jump to content

How to suppreess LoginEvent and inventory listener question


blabla123

Recommended Posts

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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!

Link to comment
Share on other sites

 

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
Link to comment
Share on other sites

 

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