Ulysses

General => Off-Topic => Topic started by: ErraticFox on January 22, 2014, 11:25:34 PM

Title: Killstreak sounds?
Post by: ErraticFox on January 22, 2014, 11:25:34 PM
Could someone help me in making a simple sandbox killstreak sound? Or tell me how I'd go about doing this? I have my sound files.
Title: Re: Killstreak sounds?
Post by: LuaTenshi on January 23, 2014, 11:02:43 AM
You would want to look at these pages...

http://wiki.garrysmod.com/page/ENTITY/OnTakeDamage (http://wiki.garrysmod.com/page/ENTITY/OnTakeDamage) -- For running things when a player takes damage. (SHARED, works on both the client and server.)
http://wiki.garrysmod.com/page/Player/Alive (http://wiki.garrysmod.com/page/Player/Alive) -- For checking if a player is alive. (SHARED, works on both the client and server.)
http://wiki.garrysmod.com/page/Player/Frags (http://wiki.garrysmod.com/page/Player/Frags) -- Check how many kills a person has. (SHARED, works on both the client and server.)
http://wiki.garrysmod.com/page/Player/Deaths (http://wiki.garrysmod.com/page/Player/Deaths) -- Check how many deaths a person has. (SHARED, works on both the client and server.)
http://wiki.garrysmod.com/page/surface/PlaySound (http://wiki.garrysmod.com/page/surface/PlaySound) -- Plays a sound of your choice. (CLIENT, works only on the client.)


Some example code to help you get started.

Code: [Select]
hook.Add("EntityTakeDamage", "YoureSpecialNameOfChoice", function( target, dmginfo )
if ( target:IsPlayer() ) then
if (target:Health() - dmginfo:GetDamage()) or not target:Alive() then
print( target:Nick() .. " has just been killed!" )
end
end
end)

If you killed me in game, the above code would write "LuaTenshi has just been killed!" in the servers console.