AngryKey Posted October 15, 2018 Share Posted October 15, 2018 (edited) NPC monster=this.npcs.closest("boss"); if(monster!=null&&!myPlayer().isUnderAttack()){ this.logoutTab.logOut();//logout } hello! but will automatically login I want it to wait for a while to login what should I do. Edited October 15, 2018 by AngryKey Quote Link to comment Share on other sites More sharing options...
Charlotte Posted October 15, 2018 Share Posted October 15, 2018 sleep? custom login handler? Quote Link to comment Share on other sites More sharing options...
AngryKey Posted October 15, 2018 Author Share Posted October 15, 2018 Just now, Charlotte said: sleep? custom login handler? Any method can be! help!!!! Quote Link to comment Share on other sites More sharing options...
jca Posted October 15, 2018 Share Posted October 15, 2018 (edited) 2 hours ago, AngryKey said: Any method can be! help!!!! I’m unclear what you are asking for, but from what I can gather is that you want to logout if a boss exists and you’re not under attack, wait, then login again? For login I would use a custom login handler to handle the event. There’s an example somewhere around here, just do a quick search. For the wait set a timer. You can store System.currentTimeMillis on logout. Then on the loop check for the required gap. If ( System.currentTimeMillis - storedTime > waitTime ) then login. Edited October 15, 2018 by jca Quote Link to comment Share on other sites More sharing options...
AngryKey Posted October 15, 2018 Author Share Posted October 15, 2018 17 minutes ago, jca said: I’m unclear what you are asking for, but from what I can gather is that you want to logout if a boss exists and you’re not under attack, wait, then login again? For login I would use a custom login handler to handle the event. There’s an example somewhere around here, just do a quick search. For the wait set a timer. You can store System.currentTimeMillis on logout. Then on the loop check for the required gap. If ( System.currentTimeMillis - storedTime > waitTime ) then login. 1.Boss exists, I will logout 2.Wait 10 minutes // The script sleeps for 10 minutes while it is running. 3.login again 4.Attack other monsters 5.Boss exists, I will logout (repeat) Quote Link to comment Share on other sites More sharing options...
Chris Posted October 15, 2018 Share Posted October 15, 2018 13 minutes ago, AngryKey said: 1.Boss exists, I will logout 2.Wait 10 minutes // The script sleeps for 10 minutes while it is running. 3.login again 4.Attack other monsters 5.Boss exists, I will logout (repeat) make your own login handler. the client handler auto logs back in launch the bot with command line arguments -norandoms Quote Link to comment Share on other sites More sharing options...
jca Posted October 15, 2018 Share Posted October 15, 2018 16 minutes ago, AngryKey said: 1.Boss exists, I will logout 2.Wait 10 minutes // The script sleeps for 10 minutes while it is running. 3.login again 4.Attack other monsters 5.Boss exists, I will logout (repeat) Okay, what I said should do the trick. Quote Link to comment Share on other sites More sharing options...
AngryKey Posted October 17, 2018 Author Share Posted October 17, 2018 On 10/16/2018 at 1:18 AM, Chris said: make your own login handler. the client handler auto logs back in launch the bot with command line arguments -norandoms Is there any other way? Quote Link to comment Share on other sites More sharing options...
Ragnar Lothbrok Posted October 17, 2018 Share Posted October 17, 2018 46 minutes ago, AngryKey said: Is there any other way? Nah you need a custom login handler - @Explv posted one in the snippets section. That should be a good starting point. Quote Link to comment Share on other sites More sharing options...
Explv Posted October 17, 2018 Share Posted October 17, 2018 (edited) 4 hours ago, AngryKey said: Is there any other way? You could override the break manager, start a break when the boss exists, and finish the break after 10 minutes. Example break manager: import org.osbot.rs07.api.Client; import org.osbot.rs07.script.RandomEvent; import org.osbot.rs07.script.RandomSolver; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Explv", name = "Break Manager", info = "", version = 0.1, logo = "") public class CustomBreakManager extends RandomSolver { private long breakDuration = -1; private long breakStartTime = -1; private boolean shouldLogout; public CustomBreakManager() { super(RandomEvent.BREAK_MANAGER); } public void startBreaking(final long breakDuration, final boolean shouldLogout) { this.breakDuration = breakDuration; this.breakStartTime = System.currentTimeMillis(); this.shouldLogout = shouldLogout; } public long getBreakStartTime() { return breakStartTime; } @Override public boolean shouldActivate() { return breakDuration > 0 && !finishedBreaking(); } public boolean finishedBreaking() { return System.currentTimeMillis() - breakStartTime >= breakDuration; } @Override public int onLoop() throws InterruptedException { if (shouldLogout && getClient().getLoginState() == Client.LoginState.LOGGED_IN) { if (getWidgets().closeOpenInterface() && getLogoutTab().logOut()) { return 1000; } } if (getMouse().isOnScreen()) { getMouse().moveOutsideScreen(); } return 3000; } } Overriding (should be only done once, in onStart): CustomBreakManager customBreakManager = new CustomBreakManager(); customBreakManager.exchangeContext(getBot()); getBot().getRandomExecutor().overrideOSBotRandom(customBreakManager); Starting a break: if (getNpcs().closest("Boss name") != null) { customBreakManager.startBreaking(TimeUnit.MINUTES.toMillis(10), true); } Edited October 17, 2018 by Explv 2 2 Quote Link to comment Share on other sites More sharing options...
AngryKey Posted October 18, 2018 Author Share Posted October 18, 2018 (edited) perfect!!!!!!! Edited October 18, 2018 by AngryKey 1 Quote Link to comment Share on other sites More sharing options...
AngryKey Posted October 18, 2018 Author Share Posted October 18, 2018 thank!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! thank thankthank 1 Quote Link to comment Share on other sites More sharing options...
AngryKey Posted October 18, 2018 Author Share Posted October 18, 2018 (edited) Thanks again!!!! Edited October 18, 2018 by AngryKey 1 Quote Link to comment Share on other sites More sharing options...