Thread Tools Display Modes
01-08-21, 04:39 PM   #1
labmixz
A Defias Bandit
Join Date: Jan 2021
Posts: 2
Iterating through all players in raid for buff

I'm sure this has been answered 1000x over, but trying to search on [these] forums, with the keywords I've been using hasn't brought me any results.

I'm looking to iterate over all the players in a raid, scanning for a buff. Without getting it to be too complex. Just wondering what the best method for doing this is? Lets say I want to look for Shadowcore Oil [spell id: 320798].


One tutorial I've found, has something like below. However, I can't see how this would iterate through all players in the raid. This seems more like it's iterating through the buffs on the player, which I need to do as well, just need to expand it to also include every other play (in raid).
Code:
local buffFound = 0
for i=1,40 do
    local name, icon, _, _, _, etime = UnitBuff("player",i)
    if name == "Shadowcore Oil" then
        buffFound = buffFound + 1
    end
end
Thanks in advance!

Edit: Of course I put this in the wrong forum :'( If someone could move it, that would be great.
  Reply With Quote
01-08-21, 05:19 PM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Take a look at https://wow.gamepedia.com/API_AuraUtil.FindAuraByName

Lua Code:
  1. local name = AuraUtil.FindAuraByName("Shadowcore Oil", 'player')
  2. if(name) then
  3. print("Buff found.")
  4. end

and

Lua Code:
  1. for i = 1, MAX_RAID_MEMBERS do
  2. local unit = format("%s%i", 'raid', i)
  3. end

Lua Code:
  1. local buffFound = 0
  2. for i = 1, MAX_RAID_MEMBERS do
  3.     local unit = format("%s%i", 'raid', i)
  4.     local name = AuraUtil.FindAuraByName("Shadowcore Oil", unit)
  5.     if(name) then
  6.         buffFound = buffFound + 1
  7.     end
  8. end
__________________
The cataclysm broke the world ... and the pandas could not fix it!

Last edited by Rilgamon : 01-08-21 at 05:24 PM.
  Reply With Quote
01-08-21, 09:49 PM   #3
labmixz
A Defias Bandit
Join Date: Jan 2021
Posts: 2
Originally Posted by Rilgamon View Post
Thanks very much!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Iterating through all players in raid for buff

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