Catalyst Gaming

General => Support & Help => Topic started by: FuriousJack95 on June 02, 2011, 07:51:27 PM

Title: Lua
Post by: FuriousJack95 on June 02, 2011, 07:51:27 PM
Trying to code something so that if a player headshots someone it plays a sound on the player and the victim and anyone near them from a list
Title: Re: Lua
Post by: Hopsin on June 03, 2011, 05:32:32 PM
what are you making this sound file for ?
Title: Re: Lua
Post by: FuriousJack95 on June 04, 2011, 03:48:40 PM
what are you making this sound file for ?
Trolling
So when someone gets a headshot it goes R U ON TEH BALL?
or FUCKIN LAG U PISASHIT
Title: Re: Lua
Post by: knoxed on June 04, 2011, 04:00:30 PM
Google
Title: Re: Lua
Post by: JoshB on June 12, 2011, 12:04:45 PM
Code: [Select]
function Headshot(ply, hitgroup, dmginfo)

if ply:Health() > dmginfo:GetDamage() then

if hitgroup == HITGROUP_HEAD then
ply:EmitSound(table.Random({pathtosound.wav, pathtosound.wav, pathtosound.wav}), 100, 100)

end

end

end

hook.Add("ScalePlayerDamage", "HeadshotStuff", Headshot)
pathtosound is the sound relative to the 'sound' directory.
Might not work. I don't know if checking the player's health on scaleplayerdamage will return their health before or after the damage is added.
Title: Re: Lua
Post by: Its Max Blad on June 12, 2011, 01:28:42 PM
Code: [Select]
function BOOMHeadShot( victim, attacker, dmginfo )
if victim:LastHitGroup() == 1 then
victim:EmitSound(table.Random({pathtosound.wav, pathtosound.wav, pathtosound.wav}), 100, 100)
end
end
hook.Add( "DoPlayerDeath", "HeadShot", BOOMHeadShot )


I couldnt be bothered to rewrite the sound playing aswell, so I stole it from JoshB as it looked fine, so "ply:EmitSound(table.Random({pathtosound.wav, pathtosound.wav, pathtosound.wav}), 100, 100)" should be credited to him, me the rest :)
SimplePortal 2.3.7 © 2008-2025, SimplePortal