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

    hi good night for all, how can i use the code for player im area, sorry for my bad english but i traying this:

     

     

    private final Area SPOT = new Area(3199, 3191, 3248,3240);

     

     

    SPOT.contains(getLocalPlayer())

     

     

    Link to comment
    Share on other sites

    Ur code should work fine, only problem i see is that u should make that variable name camelCase.

     

    http://dreambot.org/javadocs/org/dreambot/api/methods/map/Area.html

     

    contains

    public boolean contains(Entity e)

    Checks if an Area contains the Entity
     
     

     

    if(SPOT.contains(getLocalPlayer())){
         // hey im in area

    }

    Link to comment
    Share on other sites

    getLocalPlayer().getTile()

    This.

    private final Area SPOT = new Area(3199, 3191, 3248,3240);
    SPOT.contains(getPlayers().myPlayer().getTile());

    E: Don't forget the semicolons lol

    Link to comment
    Share on other sites

    This.

    private final Area SPOT = new Area(3199, 3191, 3248,3240);
    SPOT.contains(getPlayers().myPlayer().getTile());

    E: Don't forget the semicolons lol

    His original code works fine. You don't need to do that extra shit. SPOT.contains(getLocalPlayer()) works fine.

    Link to comment
    Share on other sites

    His original code works fine. You don't need to do that extra shit. SPOT.contains(getLocalPlayer()) works fine.

    It won't work if he doesn't check the tile, per my understanding

    Link to comment
    Share on other sites

    It won't work if he doesn't check the tile, per my understanding

    local player most likely inherits the tile info by default, so getLocalPlayer() would be fine

    Link to comment
    Share on other sites

    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);
        }
    
    }
     
    
    Link to comment
    Share on other sites

     

    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);
        }
    
    }
     
    

    Dat Portuguese :P Nice job henrique

    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.