Returns the class of the specified unit.
className, classFilename, classID = UnitClass("unit")
- string - unit to query, e.g. "player"
- string - Localized class name, suitable for use in user interfaces; e.g. "Mage", "Warrior", "Guerrier".
- string - Localization-independent class name, used as some table keys; e.g. "MAGE", "WARRIOR", "DEATHKNIGHT".
- number - Numeric localization-independent class ID. (Added in 5.0.1)
For any type of data tracking, use the second parameter, since it is guaranteed to stay the same in different-language clients. This is especially important in Europe, where it is not uncommon for people with e.g. german or french client software to play on english servers. You can keep track of mappings for display by remembering the output pairs in a table, e.g.:
local name, class = UnitClass("target") MyAddOn_Classes[class] = name -- store the localized name of the class