View Single Post
10-18-20, 06:02 PM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
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