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
  • Get Health Percent


    PrimoFernando

    Recommended Posts

    hey,

     

    I'm with some issues in my script when it reaches the bank it eats half of the inventory even if full health i want it to eat when it reaches 40% of the health.

     

    My EatNode:

    public class EatNode extends TaskNode {
        @Override
        public boolean accept() {
            return UserSettings.guiPrepared && getLocalPlayer().getHealthPercent() < 40 && getInventory().contains(UserSettings.foodName) && UserSettings.eatChecked;
        }
    
        @Override
        public int execute() {
            getInventory().interact(UserSettings.foodName, "Eat");
            return (int) Calculations.gRandom(1000, 200);
        }
    }
    

    what i have wrong in here?

    Link to comment
    Share on other sites

    Just use this;

    	if(getSkills().getBoostedLevels(Skill.HITPOINTS) < 50){
        		getInventory().interact(foodname,"Eat");
            		sleep(+Calculations.random(500,800));
        	}	
    
    Link to comment
    Share on other sites

     

    Just use this;

    	if(getSkills().getBoostedLevels(Skill.HITPOINTS) < 50){
        		getInventory().interact(foodname,"Eat");
            		sleep(+Calculations.random(500,800));
        	}	
    

     

    thanks man the method getLocalPlayer().getHealthPercent() must be broke right?

    Link to comment
    Share on other sites

    thanks man the method getLocalPlayer().getHealthPercent() must be broke right?

    Actually that call uses player.getHealth() hook, which is only active while in combat. Though we do have a call so you can use your skills for a health percentage rather than your current combat health, just call:

     

    getCombat().getHealthPercent(); //Click for the JavaDoc info

    Link to comment
    Share on other sites

    Actually that call uses player.getHealth() hook, which is only active while in combat. Though we do have a call so you can use your skills for a health percentage rather than your current combat health, just call:

     

    getCombat().getHealthPercent(); //Click for the JavaDoc info

     

    thanks notorious, that 2 methods cause confusion it's better to add some notes to getLocalPlayer().getHealthPercent() in api.

    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.