Thread Tools Display Modes
Prev Previous Post   Next Post Next
04/20/14, 11:46 PM   #1
mikethecoder4
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 13
Detecting Deaths

Hey there. New to Addon creating, but not to LUA or programming in general. So i had a question that I havent been able to find an answer for through research and searches. Im basically trying to make an addon that will tell me if I get a player kill or not. To start, i decided to try to make it detect when I kill anything. When I was testing on my low level character, I got it to count my kills on NPCs successfully by registering the EVENT_UNIT_DEATH_STATE_CHANGED event. However, when I went to test this on my main character in Cyrodil, killing NPCs and other mobs didnt increase the counter at all. I checked the event log using the zgoo addon (which is how i found out about the death state changed event above) and that event doesnt seem to be firing. In fact, I cant seem to find any event that happens when something does (to signify the death event I mean. of course theres xp and a bunch of other events)

Is there any way to reliably test for deaths or hook an event to them? Also is there a way to tell if they are player deaths or not?

Here is my Lua code in case its necessary
Code:
local counter = 0
 
function MyFirstAddOnUpdate()
    KillCounter_Kills:SetText(string.format("Kills: %d", counter))
end

function OnKill(eventCode, arg1, arg2)
    --print the inviter's name to chat
    counter = counter + 1
    d(arg1)
    d(arg2)
end

function OnInitialized(self)
    --Register on the top level control...
    EVENT_MANAGER:RegisterForEvent("KillCounter", EVENT_UNIT_DEATH_STATE_CHANGED, OnKill)
 	
 	SLASH_COMMANDS["/kcreset"] = function (extra)
 		-- reset counter
  		counter = 0
	end
end
 
 

ESOUI » Developer Discussions » General Authoring Discussion » Detecting Deaths


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