Ent killer

Hi, i’m making some lua coding where I spawned an entity with some health, now I made a code where whenever he got any dmg he would lose 10 hp. The only thing I need now is some way to check wich player killed/Broke the prop… Anyone here who can help me out?

Here is the code for the damage:



function GM:EntityTakeDamage( ent )
	if not ent:IsPlayer( ) then
		local hp = ent:Health( )
		local play = ent:GetPhysicsAttacker()
		PrintMessage(play .. " & " .. play:Nick())
	
		ent:SetHealth(hp - 10)
		
		if(ent:Health( ) <= 0) then
			if ply:IsPlayer( ) then
				PrintMessage("ent physics attacker: ".. ply:Nick() .."
")
			end
		end
	end
end


Read:http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexedfa.html

Use the format:


GM:EntityTakeDamage( Entity Target, Entity Inflictor(usually a weapon), Entity Attacker, Number amount of damage done, Ctakedamageinfo Damage Info )

:smiley:

You have to include all arguments in the functions attributes. Like so,

[lua]

function GM:EntityTakeDamage( ent, wep, attacker, damageDone, damageInfo )

ent:SetHealth( hp - 10 );

end

[/lua]