Reply
Thread Tools Display Modes
Unread 12-20-12, 01:52 PM   #1
gmarco
A Flamescale Wyrmkin
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 107
UnitInParty(name)

Hi all,
If I want to check if something is happening to me and to a player (name) that is in party or raid or bg with me, can I use only:

Lua Code:
  1. if destGUID == UnitGUID("player") or UnitInParty(name) then
  2.  
  3. -- code
  4.  
  5. end


UnitInParty(name) seems to me true (and so enough) if unit is in party or raid (also in different group).

Or I have to check something else like UnitInRaid(name) ?

Thanks for attention.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
gmarco is offline   Reply With Quote
Unread 12-20-12, 11:25 PM   #2
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,568
If you just want to check if they're in your group, you can use any UnitWhatever function; all of those functions will return nil if called with a name (instead of a unitID) that doesn't belong to someone in your group. eg. this will work the same way:

Code:
if destGUID == UnitGUID("player") or UnitClass(name) then
    -- code
end
Also, looking up UnitGUID("player") on every combat log is extremely inefficient. Look it up once when PLAYER_LOGIN fires (you're probably already doing other initialization stuff there) and store it in a file-level local variable, and compare the destGUID against that.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 12-21-12, 12:18 AM   #3
gmarco
A Flamescale Wyrmkin
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 107
Hi Phanx,

as usual thanks for your precious inputs.

About the second iussue, the

Lua Code:
  1. destGUID == UnitGUID("player")

I wrote it in this way here to let others readers understand what I mean, but in the addon code it was:

Lua Code:
  1. if destGUID == playerGUID or UnitInParty(destName) then

where PlayerGUID is initialized as you suggested.


About the other part of the problem, what I'd like to understand was if the function:

Lua Code:
  1. UnitInParty(name)

was true also for raids and battleground (even if the units are in differents groups).

This because I was not able to find something like UnitInGroup() (even if there is a function: IsInGroup() for the player) that could be fine for all of them (party/raid/bg) and a I was a little bit confused about this.

Your answer is, as usual, perfect because UnitClass(name) works exactly I need.

Thanks again for all your answers.

P.s.
I am writing a "fatality" like addon, named autopsy. This because the most part of the code is common with the other addon I wrote on gankers and because the "real" fatality addon continues to fire a lot of LUA errors on the blizzard raidframe. I'll post the code here for a "final" review, if someone wants to check, as soon as it is refined a little bit.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
gmarco is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua/XML Help » UnitInParty(name)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off