Atempting OnNPCKilled, not working, what am I doing wrong?
2 replies, posted
I'm trying to make a lua file that rewards you points (using the addon pointmod), and every time I kill an npc, it does not run the below lua code (It doesn't give me 5 points, it doesn't message me, it doesn't say "Test" or the msg command anywhere.)
[code]local function OnNPCKilled( victim, killer, weapon )
msg( victim:GetClass() .. " was killed by " .. killer:GetName().. " with a " .. weapon:GetClass() .. ".\n" )
killer:GivePoints( 5 )
killer:UpdatePoints()
killer:ChatMessage( "Test" )
end
[/code]
So is there anything I'm doing wrong?
I am new to lua, so don't fucking facepalm.
Also I found no errors in console, just tell me if it [I]should[/I] work and i'll be on my way, if not, tell me what I did wrong.
[editline]02:15PM[/editline]
I bet it has something to do with a hook, gmod wiki didn't mention any hooks tho
You didn't hook it.
[lua]
hook.Add("OnNPCKilled", "Give5Points", OnNPCKilled)
[/lua]
Ah, ok. Thank you.
Sorry, you need to Log In to post a reply to this thread.