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
  • Script not stopping eating.


    toxxic

    Recommended Posts

    Posted

    My script for whatever reason will catch the eat method, but not stop it until it is completely empty.
    It is a node algorithm, and I put the Eat node first.
    It will catch that it is time to eat, but wont stop until all my food is gone.

    Inventory slot 1 is not a food item. The rest are. Help!

     

    import org.dreambot.api.methods.skills.Skill;
    import org.dreambot.api.script.AbstractScript;
    
    public class Eat extends Node {
        int i = 1;
        public Eat(AbstractScript aS) {
            super(aS);
            // TODO Auto-generated constructor stub
        }
    
        @Override
        public boolean validate () throws InterruptedException {
            if(aS.getLocalPlayer().getHealthPercent() < 50 && aS.getInventory().isSlotFull(27)) {
                return true;
            }
                return false;
        }
        @Override
        public void execute () throws InterruptedException {
            KnightPockets.task = "Eating Food";
            while(aS.getLocalPlayer().getHealthPercent() < 90) {
                String nextFood = aS.getInventory().getNameForSlot(i);
                aS.getInventory().interact(nextFood, "Eat");
                if(aS.getInventory().isSlotFull(i)) {
                    i--;
                }
                if(aS.getLocalPlayer().getHealthPercent() == 100) {
                    i = 1;
                    break;
                }
                i++;
            }
        }
    }
    
    Posted

    getLocalPlayer().getHealthPercent() is always 100% if you're outside of combat.

     

    use getCombat().getHealthPercent() instead.

     

     

    (This is in the docs, I'd recommend checking em out)

    Posted

    Nevermind my post, DreamLicker told you the clue :P

    Posted

    Solved, thanks.

    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.