Jump to content
Swhit

Handing over control to random event handler

Recommended Posts

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!

Link to comment
Share on other sites

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

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.

Link to comment
Share on other sites

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? :s
 

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

 

Edited by Swhit
Link to comment
Share on other sites

 

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? :s
 

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

 

 

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

Better?:   smile.png

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

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