toxxic 5 Share Posted July 2, 2016 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++; } } } Link to comment Share on other sites More sharing options...
Dreamlicker 750 Share Posted July 2, 2016 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) Link to comment Share on other sites More sharing options...
Cardozz 46 Share Posted July 2, 2016 Nevermind my post, DreamLicker told you the clue Link to comment Share on other sites More sharing options...
toxxic 5 Author Share Posted July 3, 2016 Solved, thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.