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:
local f = CreateFrame("Frame")
local guids = {}
f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
f:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", function(self, event, ...)
if event == "NAME_PLATE_UNIT_ADDED" then
local unit = ...
guids[UnitGUID(unit)] = unit
elseif event == "NAME_PLATE_UNIT_REMOVED" then
local unit = ...
guids[UnitGUID(unit)] = nil
end
local timestamp, subevent, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool = CombatLogGetCurrentEventInfo()
if subevent == "SPELL_CAST_START" then
local unit = guids[sourceGUID]
if unit and UnitIsUnit(unit.."target", "player") and bit.band(sourceFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) > 0 then
print( format("%s cast %s on me", sourceName, spellID) )
end
end
end)