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[edit | edit source]

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

Returns[edit | edit source]

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

Example[edit | edit source]

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!");
Community content is available under CC-BY-SA unless otherwise noted.