View Full Version : [Question] - Title on NPC kill(s)?

11-02-2013, 03:09 PM
Hello Everyone,

I really wanted to ask - i saw the LUA Release of the Title on player kills, and I was wondering..
Is it possible to get that to work but instead of player kills, a certain NPC kill?

for example if I have a NPC called "Horde NPC" and he gets killed 20 times you get Private? and so on?

I saw the code "OnKilledTarget" so I am unsure if its possible to select the kills from a certain NPC..
Thats why im asking..

Thanks in advance,
- Epi.

11-02-2013, 03:28 PM
I do not think you can do that in eluna i will check the wiki to see if any methods can do it

- - - Updated - - -

I cannot find it..

the only way i could think of is like this gossip menu with all the ranks and the price of them and the price would be something that drops from the spesific mob

11-02-2013, 03:39 PM
Hmm alright thanks for the quick reply. Since there aint anything for a specific NPC is there one for total monster kills? Since it currently checks for player kills there should be a total creature kill one aswell right?

11-02-2013, 03:40 PM
I believe its possible to do this. For 100% reassurance, wait for Tommy to get online.
He will explain if you can or can not do this in Lua

11-02-2013, 03:45 PM
Thanks faded. I did check out the wiki and if it's not possible to directly gain a title from killing monsters I think it would be possible to use

player:AddLifetimeKills(val) - Adds lifetime (honorable) kills to your current lifetime kills on NPC x kill, right? That would kinda do the trick aswell.

11-02-2013, 03:46 PM
Yeah wait for Tommy if its possible he will know it

11-02-2013, 04:34 PM
You can, but it requires you to start counting kills.
You can use the server hook for creature kill.
Then count those and give the titles according to that.

Another possibility might be of you find some column in db for creature kills. It is possible that there is an achievement for creature kills or kills overall possibly. Not sure.

But it's possible to give titles on kills yes.
It should be noted that pet kills might need extra code ;)

11-02-2013, 06:20 PM
I saw the code "OnKilledTarget"

That's when the NPC kills the player, if you want to log the NPC being killed, that would be 'OnDied'.

Like Rochet2 mentioned, you can use the:

PLAYER_EVENT_ON_KILL_CREATURE = 7, - (event, killer, killed)

Server hook to log player NPC kills. http://wiki.emudevs.com/doku.php?id=eluna_hooks_registerserverhook

You could also make a table to keep the player NPC kills and just go from there like, Rochet2 mentioned as well.

11-02-2013, 06:42 PM
Hey thanks for the reply.

I used the suggestions, and I have tried to get it to add a kill on each monster kill to easy things up, but for some reason it doesnt seem to work. I am fairly new to LUA so I think I have messed up somewhere.

This is what I have atm, using the OnDead as tommy suggested:

- Adds 1 kill on monster kill
- Checks if title has been obtained
- Gives title when kills has amount reached.

local T = {
{1, 15, 1}, -- titl/titl/kills TEST

function OnDied(event, killer, killed)
for i = #T, 1, -1 do
if (killer:SetLifetimeKills(val)()+1]) then
if not killer:HasTitle(T[i][killer:GetTeam()+1]) then

RegisterServerHook(7, OnDied)

What am I doing wrong here? :)
- Epi.

11-02-2013, 08:18 PM
For one:

if (killer:SetLifetimeKills(val)()+1]) then

That isn't a boolean and "val" needs to be a number or you need to create the "val" variable. That also needs to stay out of the for loop.

I'm sure you're only doing a test run, but you will need to limit this to certain creatures you want to be killed:

if (killed:GetEntry() == ENTRYID) then
-- Continue

However, you will still have to log the player NPC kills to run a check to see if that player has killed THAT npc XX amount of times.

I edited your script, it works pretty well:


I had 104 Lifetime kills, now I have 105:



11-02-2013, 09:13 PM
Fairly easy to do by either incrementing your life time kills, as you all showed above, or specifically add an OnDied hook to a specific creature and increment a value specified to your character in a custom database table, pretty much like Rochet said. The honorable kills one would make sense in a PvP environment, while the latter would fit for a PvE environment. Those are my 2c though, seems like you two have this all sorted out already :)

11-02-2013, 09:14 PM
Thanks Tommy. I was indeed doing a test run on that one to get the basics to work. Your edit is working perfectly. Thank you so much, you are the best! :)

11-02-2013, 09:24 PM
No problem. ;)