WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   event SPELL_AURA_APPLIED occurs on every loading screen (https://www.wowinterface.com/forums/showthread.php?t=58325)

ragunragun 10-19-20 11:41 AM

event SPELL_AURA_APPLIED occurs on every loading screen
 
Hello,

I am playing a sound every time a player receives a buff but unfortunately this also occurs after each loading screen.
Since the player has +5 buffs after a loading screen the sound multiplies 5 times.
I would not like to play it after a loading screen.

Lua Code:
  1. local playerGUID = UnitGUID("player")
  2. local targetGUID = UnitGUID("target")
  3. local bossGUID = UnitGUID("bossN")
  4. local f = CreateFrame("Frame")
  5. local bossGUID = UnitGUID("boss")
  6.  
  7. f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  8. f:SetScript("OnEvent", function(self, event)
  9. self:OnEvent(event, CombatLogGetCurrentEventInfo())
  10. end)
  11.  
  12.         function f:OnEvent(event, ...)
  13.         local timestamp, subevent, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = ...
  14.  
  15.             if subevent == "SPELL_AURA_APPLIED" and destGUID == playerGUID then
  16.                     a.Sound(SoundPackValue("buff_on_self"))
  17.             end
  18.         end

Is there a possibility to detect if the buff is applied by a player or an other player as a spellcast?
Or creating a variable that would reset itself after a loading screen after 3 seconds would be better?

What would be a good way to approach this issue?

ragunragun 10-19-20 12:14 PM

I figured it out!

Lua Code:
  1. local noloadingscreen = true
  2. local function OnEvent(self, event, isInitialLogin, isReloadingUi)
  3.     if isInitialLogin or isReloadingUi then
  4.     else
  5.             noloadingscreen = nil
  6.         C_Timer.After(2, function()
  7.             noloadingscreen = true
  8.         end)
  9.     end
  10. end
  11.  
  12.  
  13.  
  14.             if subevent == "SPELL_AURA_APPLIED" and destGUID == playerGUID and noloadingscreen == true then
  15.                     a:SetTimer("buffup", 1)
  16.                     a.Sound(SoundPackValue("buff_on_self"))
  17.             end

Did the job.


All times are GMT -6. The time now is 05:47 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI