Money for an npc kill script help?!?!

Hello all again, I am still in the process of making a Garry’s Mod game mode where whenever you kill an NPC, you get money. How would I code something that would do this:

if (player kills npc) then
give money
end

thank you!!!

– Kimzey

In order to do this you’d need a money system, and I don’t know if you have one already. You could also use the EntityTakeDamage hook or something similar and check if the entity is an npc. Once you do that, also check if the amount of npc’s health is 0 and, if it is, you can use a function to give the player a certain amount of money. You can even check (as in though a series of ‘if’ statements) what kind of npc class the npc is to change the amount of money gained from different enemies.

You should be able to either make this yourself or get someone to code this for you, but without any more information no one here will be able to provide you with code. Specifically we need to see what you’ve coded already.

You can also use the two wikis (both the old one that might be a bit outdated and the new one) to find any functions/hooks you need in the future for things like this as well as find some examples/tutorials if you need them:

Even though the old one is outdated, it still has a lot of stuff the new wiki is missing. Not to mention most of it still works.

As Zyler said, you should have a money system in place.

i wouldnt use the EntityTakeDamage hook tho.
id use this http://glua.me/search/?keywords=Gamemode.OnNPCKilled