June 9, 201510 yr 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
June 10, 201510 yr 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 June 10, 201510 yr by fixthissite
June 11, 201510 yr Author 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.
June 11, 201510 yr 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. Yeah, initializing in the field is similar to initializing in the constructor.Assign the values in onStart, not the field.
June 11, 201510 yr Author Yeah, initializing in the field is similar to initializing in the constructor. Assign the values in onStart, not the field. Okay thanks ! I'll update once I do that!
June 18, 201510 yr 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); }
June 19, 201510 yr 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
June 19, 201510 yr It will not throw an NPE if the widget is not present. It will simply return null Right, my apologies.
Create an account or sign in to comment