WoW:API UnitExists: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
m (stupid mistake, don't copy and paste ><)
Line 15: Line 15:
=== Returns ===
=== Returns ===
<!-- List each return value, together with its type -->
<!-- List each return value, together with its type -->
:;exists : 1 if the unit exists, or nil if it does not exist.
:;exists : 1 if the unit exists and is in the current zone, or nil if not


== Example ==
== Example ==

Revision as of 23:20, 22 May 2009

WoW API < UnitExists

Determines if the unit exists.

exists = UnitExists("unit")

Parameters

Arguments

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

Returns

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

Example

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