Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Multiple Null Pointer Exceptions


    SpareGold

    Recommended Posts

    Whenever I gain a level on my chicken killer my console goes crazy with null pointer exceptions. Note that this does not happen if I do not kill the chicken at the same time I gain the level. If the chicekn is able to attack me afterwards and therefore exit the new level message by itself, the problem does not happen. I'm guessing it has something to do with the client not being able to get a handle on the chatbox or something. I have seen in tutorials on this site that people often make their onLoop()  like:

     

    public int onLoop() throws InterruptedException

    {

      //Code Here

    }

     

    and I was wondering if this was the current solution to this problem. Currently my onLoop() does not have the throw because it causes an error in compilation, saying:

     

    Exception InterruptedException is not compatible with throws clause in AbstractScript.onLoop()

     

    Is anyone able to explain why this happens, or a simple solution to the problem?

     

    Note: The chicken killer I am using is very simple and does nothing more than identify a killable chicken(not in combat, nearby, player is not in combat, etc) and attack it. It makes no references to the chatbox or levels.

    Link to comment
    Share on other sites

    Whenever I gain a level on my chicken killer my console goes crazy with null pointer exceptions. Note that this does not happen if I do not kill the chicken at the same time I gain the level. If the chicekn is able to attack me afterwards and therefore exit the new level message by itself, the problem does not happen. I'm guessing it has something to do with the client not being able to get a handle on the chatbox or something. I have seen in tutorials on this site that people often make their onLoop()  like:

     

    public int onLoop() throws InterruptedException

    {

      //Code Here

    }

     

    and I was wondering if this was the current solution to this problem. Currently my onLoop() does not have the throw because it causes an error in compilation, saying:

     

    Exception InterruptedException is not compatible with throws clause in AbstractScript.onLoop()

     

    Is anyone able to explain why this happens, or a simple solution to the problem?

     

    Note: The chicken killer I am using is very simple and does nothing more than identify a killable chicken(not in combat, nearby, player is not in combat, etc) and attack it. It makes no references to the chatbox or levels.

     

    If you want, add my skype: notoriouspp

     

    So you can explain your issue a bit more, and I should be able to help you out! :)

    Link to comment
    Share on other sites

    Did you add a method to handle the exception (when the level box appears as dialogue)?

     

    If not, on the onLoop(), simply include this dialog, so whenever a dialog occurs, it will click continue.

     

    getDialogues().clickContinue();


    try 

     

    public int onLoop() throws InterruptedException //(remove this)

    {

    getDialogues().clickContinue();

      //Code Here

    }

    Link to comment
    Share on other sites

    I added what Franjey suggested and have not had the error since. I think I understand the issue, but do you mind explaining how that was the solution to the problem in a little more detail? Like why it caused a null pointer exception?

     

    Thanks everyone!

     

    And thanks Notorious, I will add you on Skype when I install it on my new PC.

    Link to comment
    Share on other sites

    An InterruptedException is not the same thing as a NullPointerException, idk why you're referencing both if you're just having a npe. The exception only gets thrown if you attempt to call a method on a variable which holds a null reference.

    Link to comment
    Share on other sites

    I added what Franjey suggested and have not had the error since. I think I understand the issue, but do you mind explaining how that was the solution to the problem in a little more detail? Like why it caused a null pointer exception?

     

    Thanks everyone!

     

    And thanks Notorious, I will add you on Skype when I install it on my new PC.

     

    Null pointer exception is basically because you're making a call somewhere on a null object. 

     

    Like if you're getting NPC interaction and there are no NPCs available, it will throw a Null Pointer Exception because NPC is null,

     

    so with your script,  you're making a call to attack the chicken with a null object which was the dialog box (when it popped up because you levelled and then player kept trying to attack), so you just added a method to handle the null object

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.