WoW:API UnitLevel: Difference between revisions

Set as {{wowapi}}, copy-edited for tone, clarity
No edit summary
(Set as {{wowapi}}, copy-edited for tone, clarity)
Line 1: Line 1:
Retrieves the unit's level.
{{wowapi}}
unit being target,party,pet etc.
Returns the unit's level.


EX:
   /script SendChatMessage("Level "..UnitLevel("target"));
   /script SendChatMessage("Level "..UnitLevel("target"));


will say, if you're targeting a lvl50:
If the current target is a Level 50 [[mob]], this macro will print <tt>Level 50</tt> in your chat window. If the unit's level is unknown, i.e. a Level ?? target, or is a special boss, <tt>UnitLevel()</tt> will return -1.
Level 50
 
 
As of some patch (1.5?) it will return -1 if the level is unknown (ie, you're too low to know it, or it's a special boss)<br>
--- tarp (first post, probably broke all the design rules :) )


== Details ==
== Details ==
: Note that the value returned by <tt>UnitLevel("player")</tt> will most likely be incorrect when called in a [[Events_P_(Party,_Petition,_Pet,_PlayerBank,_Player)#PLAYER_LEVEL_UP|PLAYER_LEVEL_UP]] event handler, or shortly after leveling in general. See [[Events_P_(Party,_Petition,_Pet,_PlayerBank,_Player)#PLAYER_LEVEL_UP|PLAYER_LEVEL_UP]] arg1 for the correct level.
: Note that the value returned by <tt>UnitLevel("player")</tt> will most likely be incorrect when called in a [[Events_P_(Party,_Petition,_Pet,_PlayerBank,_Player)#PLAYER_LEVEL_UP|PLAYER_LEVEL_UP]] event handler, or shortly after leveling in general. Check [[Events_P_(Party,_Petition,_Pet,_PlayerBank,_Player)#PLAYER_LEVEL_UP|PLAYER_LEVEL_UP]] arg1 for the correct level.
 
----
{{WoW API}}
Anonymous user