WoW:API UnitExists: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(upgraded deprecated template)
m (Move page script moved page API UnitExists to API UnitExists without leaving a redirect)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{wowapi}}
{{wowapi}} __NOTOC__
<!-- Describe the purpose of the function, exhausting detail can be saved for a later section -->
Determines if the unit exists.
 
<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->
exists = UnitExists("unit")
 
== Parameters ==
=== Arguments ===
<!-- List each argument, together with its type -->
:("unit")
 
:;unit : String - The [[API TYPE UnitId|UnitId]] to query (e.g. "player", "party2", "pet", "target" etc.)
 
=== Returns ===
<!-- List each return value, together with its type -->
:;exists : 1 if the unit exists and is in the current zone, or nil if not
 
== Example ==
Just a simple example:
Just a simple example:


Line 16: Line 34:


----
----
--[[User:Morian|Morian]] 11:05, 20 Aug 2005 (EDT)

Latest revision as of 04:47, 15 August 2023

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