Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users

    Recommended Posts

    Posted

    I'm hoping this is a simple question that can be handled through Dreambot; I'm wanted to log out of one account and into another then run a script. 

    https://dreambot.org/javadocs/org/dreambot/api/script/ScriptManager.html

    ScriptManager seems to be close to what I need, but setAccount(String x) doesn't actually log into the other. Is there a way around this or do I need to build an external program that uses Dreambot's Quick start/CLI to implement this? 

    Posted (edited)

    I got something working - I think I just have to post here whenever I get stuck and then I'll figure out the answer. You need two parts for this: LoginUtility to handle the login and script manager to handle restart the script. The tricky part is stopping a script and then still be running in order to start the next. Someone smarter than me explains it well here. I have posted my code that is working which hopefully helps someone in the future

     

    public class Tester extends AbstractScript { 
    	@Override
    	public int onLoop() {
    		
    		ScriptManager sm = ScriptManager.getScriptManager();
    		
    		Tabs.logout();
    		sm.setAccount(accountName);
    		LoginUtility.login();
    		ScriptStarter ss = new ScriptStarter();
    		Thread t1 = new Thread(ss);
    		t1.start();
    
    	
    		return -1;
    	}
    }
    public class ScriptStarter implements Runnable{
        @Override
        public void run() {
            ScriptManager manager = ScriptManager.getScriptManager();
            manager.stop();
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            manager.start(scriptName);
        }

     

    Edited by TheGreatYam

    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
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.