blabla123 Posted June 22, 2015 Share Posted June 22, 2015 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 Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted June 22, 2015 Share Posted June 22, 2015 For the latter I think this could help you: client.isLoggedIn() and bot.getRandomExecutor().unregisterHook(RandomEvent.AUTO_LOGIN) Quote Link to comment Share on other sites More sharing options...
Alek Posted June 22, 2015 Share Posted June 22, 2015 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? Quote Link to comment Share on other sites More sharing options...
blabla123 Posted June 22, 2015 Author Share Posted June 22, 2015 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. Quote Link to comment Share on other sites More sharing options...
Joseph Posted June 22, 2015 Share Posted June 22, 2015 1 override the login random 2 also for the inventory listener. Use the responsive code to determine the state of the game. Im sure the listener class all it needs a simple if statement. Quote Link to comment Share on other sites More sharing options...
blabla123 Posted June 22, 2015 Author Share Posted June 22, 2015 1 override the login random 2 also for the inventory listener. Use the responsive code to determine the state of the game. Im sure the listener class all it needs a simple if statement. Hmm, I guess it should work when I rule out the increments done while hopping worlds. Quote Link to comment Share on other sites More sharing options...
blabla123 Posted June 23, 2015 Author Share Posted June 23, 2015 For the latter I think this could help you: client.isLoggedIn() and bot.getRandomExecutor().unregisterHook(RandomEvent.AUTO_LOGIN) @Flamezzz How would I then register auto_login back again? registerHook() and registerRandoms() is not working with RandomEvent.AUTO_LOGIN... Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted June 23, 2015 Share Posted June 23, 2015 (edited) @Flamezzz How would I then register auto_login back again? registerHook() and registerRandoms() is not working with RandomEvent.AUTO_LOGIN... Mhm... I've tried, without success, both overriding the AutoLogin solver and unregistering/registering it Edited June 23, 2015 by Flamezzz Quote Link to comment Share on other sites More sharing options...
Joseph Posted June 24, 2015 Share Posted June 24, 2015 @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! Quote Link to comment Share on other sites More sharing options...
blabla123 Posted June 25, 2015 Author Share Posted June 25, 2015 (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 June 25, 2015 by blabla123 1 Quote Link to comment Share on other sites More sharing options...
Joseph Posted June 25, 2015 Share Posted June 25, 2015 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. 1 Quote Link to comment Share on other sites More sharing options...