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
  • Try asking for help in the chatbox
  • Scripts can't run multiple classes?


    b14
     Share

    Recommended Posts

    Hey! So I started working on a fairly complex script today, but I ran into a little issue that I can't figure out... So basically when I code I like to use multiple classes and packages to keep things more organized for myself to improve the speed at which I code. But I noticed that as soon as I access another class using an object in my main class the script will not run:

    With this code the script will run:

    package me.b14.main;
    
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    
    @ScriptManifest(author = "B14", name = "Test", version = 1, description = "Test", category = Category.MISC)
    public class Main extends AbstractScript {
    
    
        //Breaks breaks = new Breaks();
    
        @Override
        public void onStart() {
            log("----------------------- TEST ----------------------");
            log("Starting Test...");
            log("-----------------------------------------------------------------------------");
        }
    
        @Override
        public void onExit() {
            log("----------------------- TEST ----------------------");
            log("Ending Test...");
            log("-----------------------------------------------------------------------------");
        }
    
        @Override
        public int onLoop() {
            //breaks.logout();
            log("test");
            return 600;
        }
    }

    But as soon as I remove the comment marks by the breaks object the script will no longer run:

    package me.b14.main;
    
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    
    @ScriptManifest(author = "B14", name = "Test", version = 1, description = "Test", category = Category.MISC)
    public class Main extends AbstractScript {
    
    
        Breaks breaks = new Breaks();
    
        @Override
        public void onStart() {
            log("----------------------- TEST ----------------------");
            log("Starting Test...");
            log("-----------------------------------------------------------------------------");
        }
    
        @Override
        public void onExit() {
            log("----------------------- TEST ----------------------");
            log("Ending Test...");
            log("-----------------------------------------------------------------------------");
        }
    
        @Override
        public int onLoop() {
            //breaks.logout();
            log("test");
            return 600;
        }
    }

     

    So my question is this: Does dreambot not recognize multiple classes? Am I doing  something wrong? Does dreambot not recognize multi-class objects? 

    Thank you for any help you can provide :)

    Link to comment
    Share on other sites

    32 minutes ago, StonedFarmer said:

    Are the class files in the same package? If not, try importing it. 

    Yeah they're in the same package, this is such a weird issue to run into I've tried changing my modifiers and everything but still no luck

    Link to comment
    Share on other sites

    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
     Share

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