Jump to content

Checking Idle time?


slazter

Recommended Posts

11 minutes ago, Explv said:

Seems like you are doing something wrong or need to improve your script.

Why would you need to detect if you are idle for 7 seconds? Makes no sense to me

I think like a failsafe or something. But 7 secs seems too low. E.g some scripts auto stops the script if no xp has been gained over a period of 7-10 minutes. In case it fucked up somewhere

  • Like 1
Link to comment
Share on other sites

Managed to solve it with something kind of what @Explv suggested,
 

if(myPlayer().isMoving() || myPlayer().isAnimating()){
                           time = System.currentTimeMillis();
                         }
                         else if(!myPlayer().isAnimating() && !myPlayer().isMoving()){
                           timeToMove=System.currentTimeMillis();
                           if(timeToMove>time+5000){
                             //Code
                           }
                         }
}

Mabye not the most elegant solution, but i gets the job done while i think of a better Solution :)

Link to comment
Share on other sites

It's a good solution, just be clear on how you write it so you don't get confused later (variable naming).

time variables have to be global.

 

  private boolean idleFor(int millis){

        if(myPlayer().isAnimating() || myPlayer.isMoving())
        {
            timeSinceAction = System.currentTimeMillis();
        }
        else
        {
            timeSinceIdle = System.currentTimeMillis();
        }

        return timeSinceAction + millis < timeSinceIdle;
    }

 

Edited by dreameo
  • Like 2
Link to comment
Share on other sites

17 hours ago, dreameo said:

It's a good solution, just be clear on how you write it so you don't get confused later (variable naming).

time variables have to be global.

 


  private boolean idleFor(int millis){

        if(myPlayer().isAnimating() || myPlayer.isMoving())
        {
            timeSinceAction = System.currentTimeMillis();
        }
        else
        {
            timeSinceIdle = System.currentTimeMillis();
        }

        return timeSinceAction + millis < timeSinceIdle;
    }

 

Hmm this was actually very neat, im gonna go ahead and save this snippet, thanks! :D

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