Jump to content

Knowing when you are logged in


Recommended Posts

Posted

What's the best way to definitely know if you are logged in?

client.isLoggedIn()

^ This returns true as soon as I get to the welcome screen (or even sooner). Even after pressing "Play" on the welcome screen there's a delay where it loads the maps or something. The problem I get is that I get tons of null pointer exceptions and this skips at least one tick of my loop. Also, when world hopping I believe that you get logged out for a little while (correct me if I'm wrong) and this launches my login event handler, which of course spouts out a ton of errors.

By the way,  after logging in I use worlds.getCurrentWorld() to check if I'm on the world I need to be, and when I do worlds.hop() the previous method gives me nullPointers. I do understand that when hopping there's some time when you are not in a world, but would like to handle or even evade these errors.

 

Maybe use LoginStages? http://osbot.org/api/org/osbot/rs07/api/Client.LoginStage.html

 

or maybe use LoginStates? http://osbot.org/api/org/osbot/rs07/api/Client.LoginState.html

 

If so, which combination of these two would let me know that I can do script specific stuff (logged in and ready to go), like open a bank booth.

Posted
if(getClient().getLoginStateValue() == 30)
//either
if(getClient().getLoginState().equals(Client.LoginState.LOGGED_IN))
Havent tested that though, wrote from my phone too.

 

 

Thanks. How do to check what the "30" in getLoginStateValue() stands for? 

And isn't this 

if(getClient().getLoginState().equals(Client.LoginState.LOGGED_IN))

the same as client.isLoggedIn() ?

Posted

Thanks. How do to check what the "30" in getLoginStateValue() stands for?

And isn't this

if(getClient().getLoginState().equals(Client.LoginState.LOGGED_IN))
the same as client.isLoggedIn() ?
1. The api tells you what those numbers stand for

10 = Logged out 20 = Loading please wait... 30 = Logged in

2. The client.isLoggedIn() returns true even if its loading. From what I saw you wanted a check for when everything is loaded, not loading.

Please read the API docs next time :xfeels:

  • Like 2
Posted

1. The api tells you what those numbers stand for

10 = Logged out 20 = Loading please wait... 30 = Logged in

2. The client.isLoggedIn() returns true even if its loading. From what I saw you wanted a check for when everything is loaded, not loading.

Please read the API docs next time xfeel.png

 

Damn, thanks and sorry. Slipped through my eyes.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...