Colonel_Panic Posted September 24, 2017 Share Posted September 24, 2017 I'm starting my script in CLI with -allow norandoms and when onStart is called, my script first tries to get a good starting state by checking if we're currently in a bank with: Banks.GRAND_EXCHANGE.contains(script.myPlayer()) This is immediately causing a NullPointer Exception at "org.osbot.rs07.api.map.area.contains(jk:91)" I originally thought perhaps OSBot hadn't fully initialized by the time onStart was called, so I added a 20 second sleep just to debug the problem. However, this did nothing and the crash still occurred 20 seconds later. Is this a bug, or am I doing something wrong? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted September 24, 2017 Share Posted September 24, 2017 Guessing you aren't logged in when it occurs, hence 'myPlayer' being null? Try checking loginstate Quote Link to comment Share on other sites More sharing options...
John Wick Posted September 24, 2017 Share Posted September 24, 2017 I allways use AREA.contains(myPlayer()) never saw script.myplayer Try contains(myPlayer()) only Quote Link to comment Share on other sites More sharing options...
Alek Posted September 24, 2017 Share Posted September 24, 2017 Why are you using script and not bot? 1 Quote Link to comment Share on other sites More sharing options...
Colonel_Panic Posted September 24, 2017 Author Share Posted September 24, 2017 (edited) 1 hour ago, RuneMaker4657 said: I allways use AREA.contains(myPlayer()) never saw script.myplayer Try contains(myPlayer()) only If you can simply call myPlayer, then you're in a class that inherits myPlayer (you probably extend bot or script). I have custom classes that do not inherit from OSBot classes, so I have to actually pass script around. 1 hour ago, Alek said: Why are you using script and not bot? Is there a reason I should use Bot over Script? My main class extends script and passes itself to my "Activity" classes which actually contain the logic for doing things. I got this style from guides like Apaec's Beginner Guide. I saw that Explev used a different method of having his Activity classes inherit from MethodProvider, and then called exchangeContext(getBot) on each of them: https://github.com/Explv/Tutorial-Island/blob/master/src/script/TutorialIsland.java#L22; but exchangeContext is deprecated by the looks of it. What would you recommend? 1 hour ago, FrostBug said: Guessing you aren't logged in when it occurs, hence 'myPlayer' being null? Try checking loginstate That's probably the case. I'm not sure why norandom is starting my script before my player is logged in; but maybe that boils down to me not understanding fully what norandom does. I'll make sure to not initialize without checking loginstate first. Thanks! Edited September 24, 2017 by Colonel_Panic Quote Link to comment Share on other sites More sharing options...
FrostBug Posted September 24, 2017 Share Posted September 24, 2017 1 hour ago, Colonel_Panic said: That's probably the case. I'm not sure why norandom is starting my script before my player is logged in; but maybe that boils down to me not understanding fully what norandom does. I'll make sure to not initialize without checking loginstate first. Thanks! because norandoms disabled random solvers. Autologin is a random solver Quote Link to comment Share on other sites More sharing options...