View Single Post
05-03-21, 01:00 PM   #20
Yukka
A Theradrim Guardian
 
Yukka's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2020
Posts: 60
Nice I added the code you gave above at line 23 and it works well and hide healthbars on guildies. But other people around that are not in my guild still have their healthbars under their name. Where else can I put nameplate.UnitFrame.healthBar:Hide() to hide other people healthbars?

Lua Code:
  1. local guildie={}
  2. local f=CreateFrame("Frame")
  3. f:RegisterEvent("GUILD_ROSTER_UPDATE")
  4. f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  5. f:SetScript("OnEvent",function(self,event,unit)
  6.     if event=="GUILD_ROSTER_UPDATE" then
  7.         local total=GetNumGuildMembers()
  8.         wipe(guildie)
  9.         for i=1,total do
  10.             local guid=select(17,GetGuildRosterInfo(i))
  11.             local localizedClass, englishClass, localizedRace, englishRace, sex, name, realm = GetPlayerInfoByGUID(guid)
  12.             if guid then
  13.                 guildie[guid]=true
  14.             end
  15.         end
  16.     elseif event=="NAME_PLATE_UNIT_ADDED" then
  17.         local guid = UnitGUID(unit)    
  18.         local localizedClass, englishClass, localizedRace, englishRace, sex, name, realm = GetPlayerInfoByGUID(guid)
  19.         if guildie[guid] then
  20.             PlaySound(416)
  21.             local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
  22.             nameplate.UnitFrame.name:SetTextColor(1,1,1,1)
  23.             nameplate.UnitFrame.healthBar:Hide()
  24.             print(name)
  25.         end
  26.     end
  27. end)
  Reply With Quote