API UnitSex

104,672pages on
this wiki
Add New Page
Talk0 Share
WoW API < UnitSex

Returns the gender of the specified unit.

gender_code = UnitSex("unit")

Parameters Edit

Arguments Edit

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

Returns Edit

  • 1 = Neutrum / Unknown
  • 2 = Male
  • 3 = Female

Example Edit

local genderTable = { "neuter or unknown", "male", "female" };
DEFAULT_CHAT_FRAME:AddMessage('Target is ' .. genderTable[UnitSex("target")] .. '.');

Result Edit

Target is female.

Details Edit

  • UnitSex("target") will return 1 (neuter/unknown) on "sheeped" mobs, no matter their "true" gender. (Needs reverification after 1.11). UnitSex("player") does not return 1 on "penguinification".
  • Prior to v1.11, the codes were 0=male, 1=female, 2=unknown.

Notes Edit

  • If "unit" doesn't exist (e.g. UnitSex("target") when you have no target), UnitSex() will return 0.
    Previously, it would return 2. (As seen on Talk:World of Warcraft API)

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki