WoW API: UnitPlayerControlled

Revision as of 04:47, 15 August 2023 by Move page script (talk | contribs) (Move page script moved page API UnitPlayerControlled to API UnitPlayerControlled without leaving a redirect)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

WoW API < UnitPlayerControlled

Return whether the "unit" is controlled by a player or an NPC.

UnitIsPlayerControlled = UnitPlayerControlled("unit")

ParametersEdit

ArgumentsEdit

("unit")
unit
String - The UnitId to select as a target. Using a unit's name as the unit ID only works if the unit is a member of your party.

ReturnsEdit

UnitIsPlayerControlled
UnitIsPlayerControlled
Boolean - Returns true if the "unit" is controlled by a player.
Returns false if the "unit" is an NPC.

ExampleEdit

if (UnitPlayerControlled("target")) then
  DEFAULT_CHAT_FRAME:AddMessage("Your selected target is a player.",1,1,0)
else
  DEFAULT_CHAT_FRAME:AddMessage("Your selected target is an NPC.",1,1,0)
end

InfoEdit

DEFAULT_CHAT_FRAME:AddMessage("text",r,g,b)Edit

ScrollingMessageFrame:AddMessage("text",r,g,b,id)
Valid Frame names:
DEFAULT_CHAT_FRAME
ChatFrame1 - ChatFrame7