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
  • Try asking for help in the chatbox
  • getHealthPercent() returning 100 indefinitely.


    Rubick
     Share

    Recommended Posts

    I've got an issue where getHealthPercent() returns 100 no matter what. I've got a log printing it's value and I'm looking at my character at 10% HP. What's up with it? Pretty sure it worked before.

     

    Also what's up with the suggested method being struck out in IntelliJ?

     

    AJQFvI5.png

     

     

    Edit: Apparently getHealthPercent() is only when in combat, and apparently this is the workaround:

    getSkills().getBoostedLevels(Skill.HITPOINTS)
    

    But it returns the current health points, which makes things tricky when using accounts with different HP levels, but it will do.

     

    Edit 2: This is what I needed, works outside of combat and returns a percent instead of the HP integer.

    getCombat().getHealthPercent()
    
    Edited by Rubick
    Link to comment
    Share on other sites

    I've got an issue where getHealthPercent() returns 100 no matter what. I've got a log printing it's value and I'm looking at my character at 10% HP. What's up with it? Pretty sure it worked before.

     

    Also what's up with the suggested method being struck out in IntelliJ?

     

    AJQFvI5.png

     

     

    Edit: Apparently getHealthPercent() is only when in combat, and apparently this is the workaround:

    getSkills().getBoostedLevels(Skill.HITPOINTS)
    

    But it returns the current health points, which makes things tricky when using accounts with different HP levels, but it will do.

     

    Struck out methods are deprecated, meaning you shouldn't attempt to use them.

    Link to comment
    Share on other sites

    Struck out methods are deprecated, meaning you shouldn't attempt to use them.

     

    I figured i was just curious! Thanks.

    Link to comment
    Share on other sites

    getCombat().getHealthPercent() works just fine though ;)

     

     

    If you're checking the health percent for your local player only, you can use getCombat().getHealthPercent() as it will always work and is based on your skills.

     

    Thanks gents, works perfect. Should have edited post showing i found this. :)

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

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