Jump to content

Script wont run no idea why


Qubit

Recommended Posts

I get this code when i try to run my code

 
 
[ERROR][06/09 07:20:59 PM]: Failed to start script [The Al-kharid Hermit]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.osbot.cOn.run(pj:215)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at alKharidSKiller.AKSkiller.<init>(AKSkiller.java:27)
... 8 more
 

 

Link to comment
Share on other sites

You're getting a NullPointerException at line 27 of AKSkiller.java

 

If you showed the chunk of code surrounding that line, I could help further. My guess is you're trying to use an API method within the constructor of the class that extends Script.

 

Don't use the constructor. Instead, use the onStart method to write code you want to execute when the script starts. Calling things like myPlayer() in the constructor of your script class would result in a NPE, and seeing how you're getting one in the constructor, I'm guessing that's the reason.

Edited by fixthissite
Link to comment
Share on other sites

You're getting a NullPointerException at line 27 of AKSkiller.java

 

If you showed the chunk of code surrounding that line, I could help further. My guess is you're trying to use an API method within the constructor of the class that extends Script.

 

Don't use the constructor. Instead, use the onStart method to write code you want to execute when the script starts. Calling things like myPlayer() in the constructor of your script class would result in a NPE, and seeing how you're getting one in the constructor, I'm guessing that's the reason.

61218fb80a3f43d9042d05bc07a2ac1d.png

Link to comment
Share on other sites

You're getting a NullPointerException at line 27 of AKSkiller.java

If you showed the chunk of code surrounding that line, I could help further. My guess is you're trying to use an API method within the constructor of the class that extends Script.

Don't use the constructor. Instead, use the onStart method to write code you want to execute when the script starts. Calling things like myPlayer() in the constructor of your script class would result in a NPE, and seeing how you're getting one in the constructor, I'm guessing that's the reason.

61218fb80a3f43d9042d05bc07a2ac1d.png
Yeah, initializing in the field is similar to initializing in the constructor.

Assign the values in onStart, not the field.

Link to comment
Share on other sites

 

I'm pretty certain that getWidgets().get(x, y); will actually return a NullPointerException if the widget is not open (citation needed)

Fix:

if (getWidgets().isVisible(x, y)) {
    RS2Widget widget = getWidgets().get(x, y);
}

 

It will not throw an NPE if the widget is not present. It will simply return null

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