WoW API: UnitInBattleground

From AddOn Studio
Revision as of 01:20, 7 December 2010 by WoWWiki>CosmicCleric (Created page with "{{wowapi}} __NOTOC__ <!-- Describe the purpose of the function, exhausting detail can be saved for a later section --> Used to determine the position number of the specified un…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

WoW API < UnitInBattleground


Used to determine the position number of the specified unit in the battleground raid.

position = UnitInBattleground("unit")

Parameters

Arguments

("unit")
unit
String - The UnitId to query (e.g. "player", "party2", "pet", "target" etc.)

Returns

position
Number - The position in the battleground raid of the specified unit, "nil" if outside of the battleground, and 0 if "unit" is "player" and player is the last person left standing inside of a finished battleground.

Example

local position = UnitInBattleground("player");
ChatFrame1:AddMessage('Position in battleground raid: ' .. (position or "(?)"));

Result

Prints the player's position number in the battleground raid. e.g. (depending on number left in battleground raid when call is made)
Position in battleground raid: (?)
Position in battleground raid: 0
Position in battleground raid: 12

Details

  • If 'UnitInBattleground("player")' call is made ...
Returns nil if outside of a battleground.
Returns '0' if you are the last person inside of a battleground 
after the match is over, and everybody else has left.
Returns 1-#, where # is the maximum number of players allowed 
in the battleground raid.