WoW API: GetUnitName

Revision as of 09:21, 4 March 2010 by WoWWiki>Egingell (Created page with '{{framexmlfunc|FrameXML/UnitFrame.lua}} <!-- Describe the purpose of the function, exhausting detail can be saved for a later section --> Returns the name and realm of the spec…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

WoW API < GetUnitName

"I" iconThis function is implemented in Lua here FrameXML/UnitFrame.lua.


Returns the name and realm of the specified unit.

name = GetUnitName(unit, showServerName)


Parameters

Arguments

("unit", showServerName)
unit
String - The UnitId to query (e.g. "player", "party2", "pet", "target" etc.)
showServerName
Boolean - If true, append " - [server name]" to name if it's available or FOREIGN_SERVER_LABEL (" (*)" on enUS locale) if nil or false.

Returns

name
A formatted string based on the return values of UnitName(unit).

Example

print(GetUnitName("target"))

Result

Print "Bob" if Bob is your target and is on your server or "Bob - Server Name" if Bob is your target and is from a different server.

Details

See UnitName for more details.