Thread Tools Display Modes
Prev Previous Post   Next Post Next
01-07-21, 07:39 AM   #1
n00bsteam
A Murloc Raider
Join Date: Feb 2017
Posts: 8
Detecting cast on me

Hello guys! Can u help me with some code, it didnt work, i'm new in lua
Looks like table guids allways clear
Lua Code:
  1. local f = CreateFrame("Frame")
  2.     local guids = {}
  3.     f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  4.     f:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
  5.     f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  6.     f:SetScript("OnEvent", function(self, event, ...)
  7.         if event == "NAME_PLATE_UNIT_ADDED" then
  8.             local unit = ...
  9.             guids[UnitGUID(unit)] = unit
  10.           elseif event == "NAME_PLATE_UNIT_REMOVED" then
  11.             local unit = ...
  12.             guids[UnitGUID(unit)] = nil
  13.         end
  14.         local timestamp, subevent, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool = CombatLogGetCurrentEventInfo()
  15.         if subevent == "SPELL_CAST_START" then
  16.             local unit = guids[sourceGUID]
  17.             if unit and UnitIsUnit(unit.."target", "player") and bit.band(sourceFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) > 0 then
  18.                 print( format("%s cast %s on me", sourceName, spellID) )
  19.             end
  20.         end
  21.     end)
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Detecting cast on me


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