December 16, 20169 yr Hi all, basically my script does things after its been idle for too long. I've tried multiple things on this idle timer and I can't seem to get it to function properly. On script start it works properly, but after grabbing an item, this idle function no longer starts ticking the idle timer. if (!myPlayer().isMoving() && item == null) { logB = "Idle"; newTime = (System.currentTimeMillis() - idleTime); if (newTime >= 30000) { //stuff idleTime = (System.currentTimeMillis()); } } the item should/is updating everytime the state loops Edited December 16, 20169 yr by Mushphang
December 16, 20169 yr Hi all, basically my script does things after its been idle for too long. I've tried multiple things on this idle timer and I can't seem to get it to function properly. On script start it works properly, but after grabbing an item, this idle function no longer starts ticking the idle timer. if (!myPlayer().isMoving() && item == null) { logB = "Idle"; newTime = (System.currentTimeMillis() - idleTime); if (newTime >= 30000) { //stuff idleTime = (System.currentTimeMillis()); } } the item should/is updating everytime the state loops Problem could be the item not being null but the player not moving. Don't really know the specifics for this but what I usually do is: if (myPlayer().isMoving()) { // Reset the timer if the player is moving idleTime = System.currentTimeMillis(); } newTime = (System.currentTimeMillis() - idleTime); if (newTime >= 30000) { //stuff idleTime = (System.currentTimeMillis()); } If everything is going well, reset the idleTime. If things are not going well then it will do something after 30 seconds and reset the timer Edited December 16, 20169 yr by nosepicker
December 16, 20169 yr Author Problem could be the item not being null but the player not moving. Don't really know the specifics for this but what I usually do is: if (myPlayer().isMoving()) { // Reset the timer if the player is moving idleTime = System.currentTimeMillis(); } newTime = (System.currentTimeMillis() - idleTime); if (newTime >= 30000) { //stuff idleTime = (System.currentTimeMillis()); } If everything is going well, reset the idleTime. If things are not going well then it will do something after 30 seconds and reset the timer Will test it out! Thanks So far so good, can't believe I was stumped on it for so long when it was that easy of a fix. Got so fixated on !myPlayer.isMoving() I guess. Edited December 16, 20169 yr by Mushphang
December 17, 20169 yr Here's what i use to keep my mule logged in. I just set it to move the camera every 250 seconds. public void onStart() { timer = System.currentTimeMillis(); } \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ case code if(System.currentTimeMillis() - timer >= 250000) { status = "moving camera"; int currentYaw = getCamera().getYawAngle(); getCamera().moveYaw(currentYaw + (random(-50, 70))); timer = System.currentTimeMillis(); } Could use a failsafe incase the degrees changed = 0. Worst case scenario it gets logged out and osbot logs it back in and continues.
Create an account or sign in to comment