WoW:API UnitCanAttack: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (Move page script moved page API UnitCanAttack to API UnitCanAttack without leaving a redirect) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{wowapi}} __NOTOC__ | |||
Returns 1 if the first unit can attack the second, nil otherwise. | Returns 1 if the first unit can attack the second, nil otherwise. | ||
UnitCanAttack(attacker, attacked); | canAttack = UnitCanAttack(attacker, attacked); | ||
-- | ==Parameters== | ||
;'' | ===Arguments=== | ||
:;attacker : [[UnitId]] - the unit that would initiate the attack (e.g., "player" or "target") | |||
:;attacked : [[UnitId]] - the unit that would be attacked (e.g., "player" or "target") | |||
===Returns=== | |||
:;canAttack : Bool - 1 if the ''attacker'' can attack the ''attacked'', nil otherwise. | |||
: | ==Example== | ||
if ( UnitCanAttack("player", "target") ) then | |||
DEFAULT_CHAT_FRAME:AddMessage("You can attack " .. UnitName("target") .. "."); | |||
end | |||
===Result=== | |||
If the player can attack their target, a message stating so is displayed in the default chat frame. |
Latest revision as of 04:47, 15 August 2023
← WoW API < UnitCanAttack
Returns 1 if the first unit can attack the second, nil otherwise.
canAttack = UnitCanAttack(attacker, attacked);
Parameters[edit]
Arguments[edit]
Returns[edit]
- canAttack
- Bool - 1 if the attacker can attack the attacked, nil otherwise.
Example[edit]
if ( UnitCanAttack("player", "target") ) then DEFAULT_CHAT_FRAME:AddMessage("You can attack " .. UnitName("target") .. "."); end
Result[edit]
If the player can attack their target, a message stating so is displayed in the default chat frame.