WoW API: GetUnitName
Jump to navigation
Jump to search
← WoW API < GetUnitName
- This 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.