Jump to content

NullPointer in api.map.area.contains when starting script in CLI mode with norandoms?


Colonel_Panic

Recommended Posts

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?

Link to comment
Share on other sites

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

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

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