I did the following:
- Got rid of the ugly and useless semicolons
- Cleaned up the code
- Commented where necessary
Lua Code:
local killTracker = CreateFrame( "Frame" ) -- stop global leaking
killTracker:RegisterEvent( "COMBAT_LOG_EVENT_UNFILTERED" )
killTracker:SetScript("OnEvent", function(_, _, _, event, _, sourceGUID, sourceName, _, _, destGUID, destName, destFlags)
if ( event == "PARTY_KILL" ) then
local string = sourceName.." killed "..destName
UpdateKills( string ) -- is UpdateKills a local function? it had better be!
if (sourceGUID == player) then
local _, instanceType = IsInInstance()
if ( instanceType == "pvp" ) or ( instanceType == "arena" ) then
message:AddMessage( "Killing Blow!", 1, 1, 0, 53, 3 ) -- is message a local reference? what is it, where is it?
end
end
end
end
This might still be buggy, and I'm not about to test it in game, but it should be better. PARTY_KILL was running twice because you had two things responding to it, in two different parts of your code. I moved it to one chunk.
Also, you currently don't do anything with being in an instance other than what the instance type is, so that got slimmed down.
I have no idea what references
UpdateKills and
message you have; since both are generic names, and looking over your existing code, I'm going to assume you have leaking global references. Further, there is no function reference in your posted to code to
message other than what we see, therefore the numbers after the string are meaningless and won't do anything.
But it is a start.