Hi all. How can i make a custom sounds for my models? Like a death sounds or pain sounds, when my custom player model get hurt or die. I tried to make a code, but i am a dumb and code doesnt work.
Can u show me an example code, please?
Here.
[Code]
hook.Add( "PlayerDeathSound", "MuteTheDefaultSound", function() return true end) --This function will mute the default death sound. So return it true!
hook.Add( "PlayerDeath", "ZombineSound", function( ply ) -- When the player dies...
if ply:GetModel() == "models/player/zombie_soldier.mdl" then --If the player's model is the zombine playermodel...
ply:EmitSound( "npc/zombine/zombine_die1.wav" ) --...let's emit the zombine death sound!
end
end)
[/Code]
It replaces the default death sound with the zombine death sound, if the playermodel is the zombine playermodel. You have to edit the model, the sound and the event of course.
Oh and here are some links for events you could use instead of "PlayerDeath"
[url=http://wiki.garrysmod.com/page/GM/PlayerHurt]GM:PlayerHurt[/url]
[url=http://wiki.garrysmod.com/page/GM/GetFallDamage]GM:GetFallDamage[/url]
[QUOTE=swag.exe;49502571]Here.
[Code]
hook.Add( "PlayerDeathSound", "MuteTheDefaultSound", function() return true end) --This function will mute the default death sound. So return it true!
hook.Add( "PlayerDeath", "ZombineSound", function( ply ) -- When the player dies...
if ply:GetModel() == "models/player/zombie_soldier.mdl" then --If the player's model is the zombine playermodel...
ply:EmitSound( "npc/zombine/zombine_die1.wav" ) --...let's emit the zombine death sound!
end
end)
[/Code]
It replaces the default death sound with the zombine death sound, if the playermodel is the zombine playermodel. You have to edit the model, the sound and the event of course.
Oh and here are some links for events you could use instead of "PlayerDeath"
[url=http://wiki.garrysmod.com/page/GM/PlayerHurt]GM:PlayerHurt[/url]
[url=http://wiki.garrysmod.com/page/GM/GetFallDamage]GM:GetFallDamage[/url][/QUOTE]
Thank u very much! I will try it as soon as possible.
[QUOTE=swag.exe;49502571]Here.
[Code]
hook.Add( "PlayerDeathSound", "MuteTheDefaultSound", function() return true end) --This function will mute the default death sound. So return it true!
hook.Add( "PlayerDeath", "ZombineSound", function( ply ) -- When the player dies...
if ply:GetModel() == "models/player/zombie_soldier.mdl" then --If the player's model is the zombine playermodel...
ply:EmitSound( "npc/zombine/zombine_die1.wav" ) --...let's emit the zombine death sound!
end
end)
[/Code]
It replaces the default death sound with the zombine death sound, if the playermodel is the zombine playermodel. You have to edit the model, the sound and the event of course.
Oh and here are some links for events you could use instead of "PlayerDeath"
[url=http://wiki.garrysmod.com/page/GM/PlayerHurt]GM:PlayerHurt[/url]
[url=http://wiki.garrysmod.com/page/GM/GetFallDamage]GM:GetFallDamage[/url][/QUOTE]
I tried this code, but garry's said in console, that he can't find a file, which need to play. But i wrote a correct(maybe i did a mistake) a path in a code.
What full file path is your sound in? Also, did you remember to put the file extension at the end?
Sorry, you need to Log In to post a reply to this thread.