WoW API: UnitExists

From AddOn Studio
Jump to navigation Jump to search

WoW API < UnitExists

Determines if the unit exists.

exists = UnitExists("unit")

Parameters[edit]

Arguments[edit]

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

Returns[edit]

exists
1 if the unit exists and is in the current zone, or nil if not

Example[edit]

Just a simple example:


function 1stBuff()
	if(UnitExists("target")) then 
		MeinZiel="target";
		DEFAULT_CHAT_FRAME:AddMessage("My targets 1st buff: "..(UnitBuff(MeinZiel, 1)));
	else 
		MeinZiel="player";
		DEFAULT_CHAT_FRAME:AddMessage("My own 1st buff: "..(UnitBuff(MeinZiel, 1)));
	end;
end