WoW:API UnitHealthMax: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
({{wowapi}}, update)
(added note about 0 return for non exist unit)
Line 5: Line 5:


==Parameters==
==Parameters==
===Arguments===
:;unit : [[UnitId]] -  the unit whose max health to query.
:;unit : [[UnitId]] -  the unit whose max health to query.
===Returns===
 
:;max_health : Integer - the maximum health of the specified unit
==Returns==
:;max_health : Integer - the maximum health of the specified unit, returns 0 if the specified unit does not exist (eg. "target" given but there is no target)


==Example==
==Example==
 
Print the maximum health of ''player'' and ''target'' units to the chat window:
  ChatFrame1:AddMessage('Player max health: ' .. UnitHealthMax("player") .. " HP");
  ChatFrame1:AddMessage('Player max health: ' .. UnitHealthMax("player") .. " HP");
  ChatFrame1:AddMessage('Target max health: ' .. UnitHealthMax("target").. "%");
  ChatFrame1:AddMessage('Target max health: ' .. UnitHealthMax("target").. "%");
===Result===
Prints the maximum health of ''player'' and ''target'' units to the chat window.

Revision as of 12:33, 12 October 2007

WoW API < UnitHealthMax

Returns the maximum health of the specified unit. Returns the exact hitpoints for friendly players and pets in your raid/party, percentages otherwise.

local max_health = UnitHealthMax(unit);

Parameters

unit
UnitId - the unit whose max health to query.

Returns

max_health
Integer - the maximum health of the specified unit, returns 0 if the specified unit does not exist (eg. "target" given but there is no target)

Example

Print the maximum health of player and target units to the chat window:

ChatFrame1:AddMessage('Player max health: ' .. UnitHealthMax("player") .. " HP");
ChatFrame1:AddMessage('Target max health: ' .. UnitHealthMax("target").. "%");