Quantcast
Player died event - WoWInterface
Thread Tools Display Modes
10-18-20, 05:45 PM   #1
ragunragun
A Murloc Raider
Join Date: Oct 2020
Posts: 4
Player died event

Hi,

Im trying to play a sound on players death, but it does not work for me

Lua Code:
  1. local function OnEvent(self, event, ...)
  2.  
  3. if event == "COMBAT_LOG_EVENT_UNFILTERED" then
  4.            
  5. local Event = select(2, ...)
  6. local sourceGUID = select(4, ...)
  7. local GUID = select(8, ...)
  8. local SpellName = select(13, ...)
  9. local EventType = select(15, ...)
  10.  
  11. if Event == "UNIT_DIED" then
  12. if GUID == UnitGUID("player") then
  13.  
  14. a.Sound(SoundPackValue("player_died"))
  15. end
  16. end
  17. end

and every time I buff myself

Lua Code:
  1. if Event == "SPELL_AURA_APPLIED" and GUID == UnitGUID("player") then
  2. if EventType == "BUFF" then
  3.  
  4. a.Sound(SoundPackValue("buff_on_self"))
  5.  
  6. end
  7. end

Could you please help me understand why doesn't it work and correct me?

Thank you so much for help.
  Reply With Quote
10-18-20, 06:02 PM   #2
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 946
You need to use CombatLogGetCurrentEventInfo() and you should post your full code if you want to get better help with your code
https://wow.gamepedia.com/COMBAT_LOG_EVENT
Lua Code:
  1. local playerGUID = UnitGUID("player")
  2.  
  3. local f = CreateFrame("Frame")
  4. f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  5. f:SetScript("OnEvent", function(self, event)
  6.     self:OnEvent(event, CombatLogGetCurrentEventInfo())
  7. end)
  8.  
  9. function f:OnEvent(event, ...)
  10.     local timestamp, subevent, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = ...
  11.  
  12.     if subevent == "UNIT_DIED" and destGUID == playerGUID then
  13.         print("You died.")
  14.     end
  15. end

As for just the player dying, that can be easier done with PLAYER_DEAD
Lua Code:
  1. local function OnEvent(self, event, ...)
  2.     print("You died.")
  3. end
  4.  
  5. local f = CreateFrame("Frame")
  6. f:RegisterEvent("PLAYER_DEAD")
  7. f:SetScript("OnEvent", OnEvent)
  Reply With Quote
10-19-20, 08:19 AM   #3
ragunragun
A Murloc Raider
Join Date: Oct 2020
Posts: 4
Works like a charm! Thank you!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Player died event

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