Jump to content

How can I get the current HP of a Player?


Team Cape

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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