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
  • Paint/Timer Help


    isystem32
     Share

    Recommended Posts

    Hi I'm working on my first script. It's a basic willow power cutter.

     

    I can't seem to get a functional timer (Hours:Minutes:Seconds) running on the paint.  Can someone give me any tips or point me to the right direction. Thanks!

     

    Source code below: 

     

    import org.dreambot.api.methods.skills.Skill;
    import org.dreambot.api.methods.skills.Skills;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.listener.PaintListener;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    import java.awt.*;
    
    @ScriptManifest(author = "iSystem", name = "Willow Cutter", version = 1.0, description = "Woodcutter", category = Category.WOODCUTTING)
    
    
    public class Woodcutter extends AbstractScript implements PaintListener {
    
            public int getTime() {
            int seconds = 1000;
            int minutes = seconds / 60;
            int hours = minutes / 60;
            int  days = hours / 24;
    
    
                return seconds;
            }
    
    
        @Override
        public void onPaint(Graphics g) {
            g.drawString("Experience remaining to level " +(Skills.getExperienceToLevel(Skill.WOODCUTTING)), 10, 10);
            g.drawString("Time ran " + getTime(), 15, 15);
        }
    
    
    
    
        public void onStart() {
            log("starting");
    
    
    
        }
    
        @Override
        public int onLoop() {
            if (getInventory().isFull()) {
                getInventory().dropAll("Willow Logs");
                sleep(300, 500);
            } else {
                GameObject willow = getGameObjects().closest("Willow");
                if (willow != null) {
                    willow.interact("Chop down");
                    sleep(500, 600);
                    sleepUntil(() -> !getLocalPlayer().isAnimating() , 15000);
    
    
                }
            }
    
            return 300;
        }
    
    
    
    
    
    
        public void onExit() {
            log("finished");
    
        }
    }

     

    Edited by isystem32
    Link to comment
    Share on other sites

    1 hour ago, isystem32 said:

    Hi I'm working on my first script. It's a basic willow power cutter.

     

    I can't seem to get a functional timer (Hours:Minutes:Seconds) running on the paint.  Can someone give me any tips or point me to the right direction. Thanks!

     

    Source code below: 

     

    import org.dreambot.api.methods.skills.Skill;
    import org.dreambot.api.methods.skills.Skills;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.listener.PaintListener;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    import java.awt.*;
    
    @ScriptManifest(author = "iSystem", name = "Willow Cutter", version = 1.0, description = "Woodcutter", category = Category.WOODCUTTING)
    
    
    public class Woodcutter extends AbstractScript implements PaintListener {
    
            public int getTime() {
            int seconds = 1000;
            int minutes = seconds / 60;
            int hours = minutes / 60;
            int  days = hours / 24;
    
    
                return seconds;
            }
    
    
        @Override
        public void onPaint(Graphics g) {
            g.drawString("Experience remaining to level " +(Skills.getExperienceToLevel(Skill.WOODCUTTING)), 10, 10);
            g.drawString("Time ran " + getTime(), 15, 15);
        }
    
    
    
    
        public void onStart() {
            log("starting");
    
    
    
        }
    
        @Override
        public int onLoop() {
            if (getInventory().isFull()) {
                getInventory().dropAll("Willow Logs");
                sleep(300, 500);
            } else {
                GameObject willow = getGameObjects().closest("Willow");
                if (willow != null) {
                    willow.interact("Chop down");
                    sleep(500, 600);
                    sleepUntil(() -> !getLocalPlayer().isAnimating() , 15000);
    
    
                }
            }
    
            return 300;
        }
    
    
    
    
    
    
        public void onExit() {
            log("finished");
    
        }
    }

     

    Not on computer 
    But onStart you need to get time

    Link to comment
    Share on other sites

    3 hours ago, ethan45 said:

    Not on computer 
    But onStart you need to get time

    Hello @ethan45 , you can use this class :) 
     

    public class Time {
    
        public long startTime;
    
        public Time() {
    
        }
    
        public static String eclapsedtime(Long startTime) {
            long elapsed;
            elapsed = ((System.currentTimeMillis() - startTime) / 1000);
    
            return String.format("%02d:%02d:%02d", elapsed / 3600, (elapsed % 3600) / 60, (elapsed % 60));
        }
    
        public static long eclapsedsec(Long startTime) {
            long elapsed;
            elapsed = ((System.currentTimeMillis() - startTime) / 1000);
            return elapsed;
        }
    
        public long getStartTime() {
            return startTime;
        }
    
        public void setStartTime(long startTime) {
            this.startTime = startTime;
        }
    }
    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.