Jump to content

How can I get the current HP of a Player?


Recommended Posts

Posted (edited)

getCurrentHealth()

 

This is only updated while in combat and will return 0 if they have never been detected in combat, the associated getCombatTime() will return -1000 if the Player instance has never been detected in combat.

Edited by Token
  • Like 2
Posted (edited)

getCurrentHealth()

 

This is only updated while in combat and will return 0 if they have never been detected in combat, the associated getCombatTime() will return -1000 if the Player instance has never been detected in combat.

 

Thanks so much for the help! 

Would you please show me an example of how it's used?

Do I need to write 'character.getCurrentHealth()'? What object should I attach the method to?

Edited by Imateamcape
Posted

Thanks so much for the help! 

Would you please show me an example of how it's used?

Do I need to write 'character.getCurrentHealth()'? What object should I attach the method to?

Player x = players.closest("Johnny");
if (x.getCombatTime() == -1000) {
    log("Johnny has never been in combat; we can't know his hp");
} else {
    log("Johnny's hp is: " + x.getCurrentHealth());
}
  • Like 1

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...