slazter Posted July 18, 2017 Share Posted July 18, 2017 Is there any way to check how long the bot has been in Idle for? Say that i want my bot to do certain things, but in case it idles for say 7sec+ for etc, i want it to move position? Quote Link to comment Share on other sites More sharing options...
Explv Posted July 18, 2017 Share Posted July 18, 2017 (edited) 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 Edited July 18, 2017 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Viston Posted July 18, 2017 Share Posted July 18, 2017 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 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted July 18, 2017 Share Posted July 18, 2017 8 minutes ago, Visty said: 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 You should probably aim for your script to not fuck up then 3 Quote Link to comment Share on other sites More sharing options...
Viston Posted July 18, 2017 Share Posted July 18, 2017 2 minutes ago, Explv said: You should probably aim for your script to not fuck up then True father 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted July 18, 2017 Share Posted July 18, 2017 (edited) @slazter if you really have to do it, then you can probably make use of the isAnimating and isMoving methods in the Character class, in combination with some kind of timer. Edited July 18, 2017 by Explv Quote Link to comment Share on other sites More sharing options...
Abysm Posted July 18, 2017 Share Posted July 18, 2017 Check plague doctor's cannonball maker he has something like that done for the sleep I think? Quote Link to comment Share on other sites More sharing options...
slazter Posted July 18, 2017 Author Share Posted July 18, 2017 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 Quote Link to comment Share on other sites More sharing options...
dreameo Posted July 19, 2017 Share Posted July 19, 2017 (edited) 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 July 19, 2017 by dreameo 2 Quote Link to comment Share on other sites More sharing options...
slazter Posted July 19, 2017 Author Share Posted July 19, 2017 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! Quote Link to comment Share on other sites More sharing options...
dreameo Posted July 20, 2017 Share Posted July 20, 2017 Yeah, there will be a lot of methods that you use often, keep them clean and separate. Reduces code duplication and makes life easier. Ex: a timer class Quote Link to comment Share on other sites More sharing options...
mwd1993 Posted July 20, 2017 Share Posted July 20, 2017 Toss the check in it's own thread :D. Quote Link to comment Share on other sites More sharing options...