Sound OnTakeDamage

Hi, i try to put this …


	
local function OnTakeDamage(damage)
if ply:OnTakeDamage(IsBulletDamage) then
  	if(ply:IsPlayer() and ply:Team() == TEAM_PC_RECRUE or ply:Team() == TEAM_PC or ply:Team() == TEAM_PC_MEDIC or ply:Team() == TEAM_PC_ELITE or ply:Team() == TEAM_PC_INTERVENTION or ply:Team() == TEAM_PC_OFC ) then 
		ply:EmitSound("npc/metropolice/pain"..math.random(1,4)..".wav") end 
		end end
hook.Add("OnTakeDamage","MiliceDamage", OnTakeDamage)


…In my gamemode to make a sound when the Team is damaged but that makes nothing.

Please help me :confused:

I would probably use this hook: http://wiki.garrysmod.com/page/GM/EntityTakeDamage

Thank you !

[editline]30th November 2014[/editline]

re :
I put this :


function EntityTakeDamage( target, dmginfo )

	 if ((target:IsPlayer() and dmginfo:IsBulletDamage())and ply:Team() == TEAM_PC_RECRUE or ply:Team() == TEAM_PC or ply:Team() == TEAM_PC_MEDIC or ply:Team() == TEAM_PC_ELITE or ply:Team() == TEAM_PC_INTERVENTION or ply:Team() == TEAM_PC_OFC ) then
	
		 ply:EmitSound("npc/metropolice/pain"..math.random(1,4)..".wav")

	 end
	
	 return dmginfo

end
hook.Add("EntityTakeDamage","MilicePain",EntityTakeDamage)

and nothing again :confused:

[editline]30th November 2014[/editline]

Oh, I put it in “autorun/lua/client” is it another folder ?

[editline]30th November 2014[/editline]

Oh, I put it in “lua/autorun/client” is it another folder ?

It goes in lua/autorun/server

Oh, ok

[editline]30th November 2014[/editline]

Thank you, it work.

Now, I don’t know how, but I would like to make the sound activate his self only 1/2 bullet.

Can you help me ?

[editline]30th November 2014[/editline]

i find how, thank you all :slight_smile: