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
  • Code for player im area


    henrique190

    Recommended Posts

    • 1 month later...

     

    Thanks all for the greatest support, with your help I did my first script! thank you all

    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.utilities.impl.Condition;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    @ScriptManifest(author = "henrique", name = "BR Chopper", version = 1.0, description = "Corta Arvores", category = Category.WOODCUTTING)
    public class main extends AbstractScript {
    
        private final Tile Fugir = new Tile(3000, 3000, 0);
    
        public boolean EmAtaque() {
            return getLocalPlayer().isInCombat();
        }
    
        public boolean Correr() {
            // if (getWalking().isRunEnabled())
            // return getWalking().walk(Fugir);
            // else {
            // getWalking().toggleRun();
            return getWalking().walk(Fugir);
            // }
        }
    
        String Axe[] = { "Rune axe", "Bronze axe", "Iron axe", "Steel Axe",
                "Black axe", "Mithril axe", "Adamant axe" };
    
        private final Tile IR_SPOT = new Tile(3177, 3250, 0);
        private final Area Spot = new Area(3177, 3178, 3250, 3254, 0);
    
        public boolean maldito() {
            GameObject Tree = getGameObjects().closest("Tree");
            return Tree.distance() <= 5;
        }
    
        public Boolean movendo() {
            return getLocalPlayer().isMoving();
        }
    
        public boolean Anima() {
            return getLocalPlayer().getAnimation() == -1;
        }
    
        public boolean invcheio() {
            return (getInventory().isFull());
        }
    
        public boolean podecortar() {
            GameObject Tree = getGameObjects().closest("Tree");
            return (Tree != null && Tree.isOnScreen());
    
        }
    
        public boolean lugar() {
            return Spot.contains(getLocalPlayer().getTile());
        }
    
        private enum State {
            IR, CORTAR, DROPAR, ESPERAR;
        };
    
        private State getState() {
    
            if (lugar()) {
                log("lugar");
    
                if (invcheio()) {
                    log("inv");
                    return State.DROPAR;
                } else if (podecortar() && Anima() && !movendo() && lugar()) {
                    log("pode cortar");
                    return State.CORTAR;
    
                }
    
                return State.ESPERAR;
            } else {
                log("IR");
    
                return State.IR;
            }
        }
    
        public void onStart() {
            log("Iniciando");
            log("Vamos");
        }
    
        public void onExit() {
            log("Iniciando");
            log("Obrigado por usar, volte sempre!!");
        }
    
        @Override
        public int onLoop() {
    
            switch (getState()) {
    
            case IR:
                getWalking().walk(IR_SPOT);
                break;
    
            case CORTAR:
    
                if (maldito()) {
    
                    GameObject Tree = getGameObjects().closest("Tree");
                    Tree.interact("Chop down");
                    sleepUntil(new Condition() {
                        public boolean verify() {
                            return getLocalPlayer().getAnimation() == -1;
                        }
                    }, Calculations.random(1800, 2400));
                }
    
                break;
            case DROPAR:
                getInventory().dropAllExcept(Axe);
                break;
    
            case ESPERAR:
                Calculations.random(500, 600);
                break;
    
            }
    
            return Calculations.random(500, 600);
        }
    
    }
     
    

    You should make all your methods start with a lowercase letter. For example public boolean Anima() --> public boolean anima().

    Hope I helped!

    -Club

     

    EDIT: heres a good article if you would like to look into naming methods- http://www.cwu.edu/~gellenbe/javastyle/method.html

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

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