Wowpedia
Advertisement
Wowpedia
240,452
pages

Returns the gender of the specified unit.

gender = UnitSex(unit)

Arguments

unit 
string - UnitId

Returns

sex 
number (nilable) - One of the following values, or nil if the unit does not exist
  • 1 = Neutrum or Unknown
  • 2 = Male
  • 3 = Female

Example

local genders = {"unknown", "male", "female"}
if UnitExists("target") then
	print("The target is "..genders[UnitSex("target")])
end

Details

  • Most non-humanoid mobs/creatures will appear as Neutrum/Unknown.
  • Player characters currently appear as either Male or Female.

Patch changes

  • WoW Icon update.png Patch 1.11.0 / API (2006-06-19): Return values changed to 1 unknown, 2 male, 3 female
    Previously returned 0 male, 1 female, 2 unknown
  • At an unknown time after 1.10, sheeped targets stopped returning 'unknown' and began providing the 'true' gender

See also

Advertisement