if player kills a zombie give them cash?

I’ve setup my gamemode got the money system working, the only problem is you cant gain money exept at the start of the round

how would i make it so that for example if the player kills a npc_zombie give them 10 cash using this for example


function ZombieKill()
local cash = ply:GetPData("money")
--[[Code here]]--
then
ply:SetMoney( cash + 10 )
end

If you just wanted it for killing a single type of zombie, you would do
[LUA]
local function ZombieCash( npc, ply, weapon )
local class = npc:GetClass()
local cash = ply:GetPData( “money”, 0 )

if class == "npc_zombie" then
	ply:SetMoney( cash + 10 )
end

end
hook.Add( “OnNPCKilled”, “ZombieCash”, ZombieCash ) – hook it to OnNPCKilled, so our function is run when a npc is killed
[/LUA]

However, if you wanted to do it so you could have multiple types of zombies, you’d use a table;
[LUA]
local zombieDollaz = {}
zombieDollaz[“npc_antlion”] = 15
zombieDollaz[“npc_zombie”] = 10
zombieDollaz[“npc_headcrab”] = 5

local function ZombieCash( npc, ply, weapon )
local class = npc:GetClass()
local cash = ply:GetPData( “money”, 0 )

if zombieDollaz[class] then
	ply:SetMoney( cash + zombieDollaz[class] ) -- this way, we check if the type of zombie was in our table, and if so we give the money specified
end

end
hook.Add( “OnNPCKilled”, “ZombieCash”, ZombieCash ) – hook it to OnNPCKilled, so our function is run when a npc is killed
[/LUA]

Hope this helps

Thanks so much