Macro If (UnitIsPlayer("target")) Help

Macro If (UnitIsPlayer("target")) Help

by rdrmdr » Thu Mar 24, 2016 11:11 pm

Hi, I have some code really close to work but I'm stuck with the if the target is a player or a npc.
What I want is something like this:

Code: Select all
/run If(UnitIsPlayer("target")) then
SendChatMessage(UnitName("target").." is a level "..UnitLevel("target").." "..UnitRace("target").." "..UnitClass("target").." player.")
Else
SendChatMessage(UnitName("target").." is a level "..UnitLevel("target").." NPC.")
End

...but that doesn't work.
Thanks for the help.
rdrmdr
Grunt
Grunt
 

Re: Macro If (UnitIsPlayer("target")) Help

by Dreez » Thu Mar 24, 2016 11:53 pm

rdrmdr wrote:Hi, I have some code really close to work but I'm stuck with the if the target is a player or a npc.
What I want is something like this:

Code: Select all
/run If(UnitIsPlayer("target")) then
SendChatMessage(UnitName("target").." is a level "..UnitLevel("target").." "..UnitRace("target").." "..UnitClass("target").." player.")
Else
SendChatMessage(UnitName("target").." is a level "..UnitLevel("target").." NPC.")
End

...but that doesn't work.
Thanks for the help.

it actually does work, just make sure you're paying attention to lower / upper case words
Code: Select all
/run u=UnitName l=UnitLevel if(UnitIsPlayer("target")) then ChatFrame1:AddMessage(u("target")..l("target").." "..UnitRace("target").." "..UnitClass("target").." p.")else ChatFrame1:AddMessage(u("target").." is a level "..l("target").." NPC.")end
works (just had to shorten it down a bit, you'll figure it out now I guess)

if end else

all have to be lower case only

Code: Select all
/run if(UnitIsPlayer("target")) then SendChatMessage(UnitName("target").." is a level "..UnitLevel("target").." "..UnitRace("target").." "..UnitClass("target").." player.")else SendChatMessage(UnitName("target").." is a level "..UnitLevel("target").." NPC.")end

the original (now working) version
Dreez - PvP server
<Endzeit>
User avatar
Dreez
Knight-Lieutenant
Knight-Lieutenant
 

Re: Macro If (UnitIsPlayer("target")) Help

by rdrmdr » Fri Mar 25, 2016 12:12 am

Thanks for the quick reply!
It works perfectly.
rdrmdr
Grunt
Grunt
 


Return to Addons & macros