WoW API: UnitIsFriend

From AddOn Studio
Revision as of 04:47, 15 August 2023 by Move page script (talk) (Move page script moved page API UnitIsFriend to API UnitIsFriend without leaving a redirect)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

WoW API < UnitIsFriend

This function will determine whether two units are friendly to each other (i.e. able to help each other in combat).

isFriend = UnitIsFriend("unit","otherunit");

Arguments

unit
String - A valid unit.
otherunit
String - A valid unit.

Returns

IsFriend
Boolean flag - 1 if otherunit is friendly to unit; nil otherwise.

Example

The following snippet outputs a message when the player has a hostile target.

if UnitExists("target") and not UnitIsFriend("player", "target") then
 print(UnitName("target") .. " is evil! Run!");
end