Swhit Posted May 15, 2015 Share Posted May 15, 2015 Hello all, I have a pretty straightforward problem on my hands. I use interact("bank chest") to open up my bank, which is fine for all scenarios except for when I have to put in my PIN. What happens in this case is my script times out, the random event handler takes over and puts my pin in, then my script continues to run. How do I give the random event handler control without my script timing out first? Thanks! Quote Link to comment Share on other sites More sharing options...
FrostBug Posted May 15, 2015 Share Posted May 15, 2015 (edited) The random event handler probably just takes time to start up because all the handlers are evaluated in a set time interval. If you find that your script is preventing the handler from starting; I suppose you should just make your code easier to interrupt out of. Edited May 15, 2015 by FrostBug Quote Link to comment Share on other sites More sharing options...
Precise Posted May 15, 2015 Share Posted May 15, 2015 Hello all, I have a pretty straightforward problem on my hands. I use interact("bank chest") to open up my bank, which is fine for all scenarios except for when I have to put in my PIN. What happens in this case is my script times out, the random event handler takes over and puts my pin in, then my script continues to run. How do I give the random event handler control without my script timing out first? Thanks! How does your script timeout? also post code of where in the script it handles the bank etc. The PIN handler shouldn't be posing any issues as it is the code you written which is causing it to conflict. post your code so we can see more of what is going on. Quote Link to comment Share on other sites More sharing options...
Swhit Posted May 15, 2015 Author Share Posted May 15, 2015 (edited) rsbot output: [iNFO][bot #1][05/15 08:25:10 AM]: case: BANK [iNFO][bot #1][05/15 08:25:10 AM]: mouse speed is 3 [WARN][bot #1][05/15 08:25:15 AM]: Event executor is taking too long to suspend; terminating now... [iNFO][bot #1][05/15 08:25:16 AM]: Started random solver : BankPin Solver [iNFO][bot #1][05/15 08:25:38 AM]: Random solver exited : BankPin Solver [iNFO][bot #1][05/15 08:25:38 AM]: case: BANK [iNFO][bot #1][05/15 08:25:38 AM]: mouse speed is 3 Applicable code: case BANK: if (myPlayer().isAnimating() && timePassed(500) ) { log("player animating"); } log("case: BANK"); //banking RS2Object bankBooth = objects.closest("Bank chest"); if (bankBooth != null) { //getMouse().setSpeed(3); //log("mouse speed is 3"); if (bankBooth.interact("Use")) { log("banking"); while(!bank.isOpen() ) { sleep(250); } bank.depositAllExcept("Dragon pickaxe"); log("deposited is true"); deposited = true; } } getMouse().setSpeed(6); break; Btw, how do I get my code to keep it's formatting? Also, my timer isn't working, if anyone wants to help me with that as well.. (in main) long startTime; long curTime; long newTime; XClient XCinstance; later on, still in main.. private boolean timePassed(long MStime) { curTime = XCinstance.getCurrentTime(); log("current time: " + curTime); boolean hasPassed = ((curTime - newTime) >= MStime) ? true : false; newTime = curTime; return hasPassed; } trying to use it.. if (myPlayer().isAnimating() && timePassed(500) ) { log("player animating"); } It gave me a null ptr exception for some reason: [ERROR][bot #1][05/15 08:33:28 AM]: Error in script executor! java.lang.NullPointerException at main.timePassed(main.java:76) at main.onLoop(main.java:205) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(qj:191) at java.lang.Thread.run(Unknown Source) Thanks Edited May 15, 2015 by Swhit Quote Link to comment Share on other sites More sharing options...
FrostBug Posted May 15, 2015 Share Posted May 15, 2015 (edited) rsbot output: [iNFO][bot #1][05/15 08:25:10 AM]: case: BANK [iNFO][bot #1][05/15 08:25:10 AM]: mouse speed is 3 [WARN][bot #1][05/15 08:25:15 AM]: Event executor is taking too long to suspend; terminating now... [iNFO][bot #1][05/15 08:25:16 AM]: Started random solver : BankPin Solver [iNFO][bot #1][05/15 08:25:38 AM]: Random solver exited : BankPin Solver [iNFO][bot #1][05/15 08:25:38 AM]: case: BANK [iNFO][bot #1][05/15 08:25:38 AM]: mouse speed is 3 Applicable code: case BANK: if (myPlayer().isAnimating() && timePassed(500) ) { log("player animating"); } log("case: BANK"); //banking RS2Object bankBooth = objects.closest("Bank chest"); if (bankBooth != null) { //getMouse().setSpeed(3); //log("mouse speed is 3"); if (bankBooth.interact("Use")) { log("banking"); while(!bank.isOpen() ) { sleep(250); } bank.depositAllExcept("Dragon pickaxe"); log("deposited is true"); deposited = true; } } getMouse().setSpeed(6); break; Btw, how do I get my code to keep it's formatting? Also, my timer isn't working, if anyone wants to help me with that as well.. (in main) long startTime; long curTime; long newTime; XClient XCinstance; later on, still in main.. private boolean timePassed(long MStime) { curTime = XCinstance.getCurrentTime(); log("current time: " + curTime); boolean hasPassed = ((curTime - newTime) >= MStime) ? true : false; newTime = curTime; return hasPassed; } trying to use it.. if (myPlayer().isAnimating() && timePassed(500) ) { log("player animating"); } It gave me a null ptr exception for some reason: [ERROR][bot #1][05/15 08:33:28 AM]: Error in script executor! java.lang.NullPointerException at main.timePassed(main.java:76) at main.onLoop(main.java:205) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(qj:191) at java.lang.Thread.run(Unknown Source) Thanks First off, never do this: while(!bank.isOpen() ) { sleep(250); } as it will eventually fail to open the bank and fall into an infinite sleep. Your timer probably does not work because you for some reason are trying to use an ininitialized instance of XClient, which is a class used for injection (I assume). use System.currentTimeMillis() to get the time since epoch instead. Edited May 15, 2015 by FrostBug Quote Link to comment Share on other sites More sharing options...
Swhit Posted May 15, 2015 Author Share Posted May 15, 2015 (edited) Better?: int failSafe = 0; while(!bank.isOpen() && failSafe < 10) { sleep(250); failSafe++; } Also, I got the timer working after using your suggestion. Thanks! Still having an issue with the random solver though: [INFO][Bot #1][05/15 09:02:10 AM]: banking [WARN][Bot #1][05/15 09:02:16 AM]: Event executor is taking too long to suspend; terminating now... [INFO][Bot #1][05/15 09:02:17 AM]: Started random solver : BankPin Solver [INFO][Bot #1][05/15 09:02:22 AM]: Random solver exited : BankPin Solver [INFO][Bot #1][05/15 09:02:22 AM]: case: BANK Edited May 15, 2015 by Swhit Quote Link to comment Share on other sites More sharing options...