I'm making a game mode for Garry's Mod, and I'm trying to write a system in which I play sounds only for certain players. The problem I'm running across is that doing so from server-side would take a lot of bandwidth, but I'm not sure how I could reliably do it from the client side. None of the Garry's Mod sound functions seem to take player entity arguments, and surface.playsound would resort back to the method of server telling the client what sounds to play for every sound played.


Only took 5 years, but to answer your question:

hook.Add("PlayerDeathSound", "DeFlatline", function() return true end) 
local noise = Sound("death.wav") 
hook.Add("PlayerDeath", "NewSound", function(vic,unused1,unused2) vic:EmitSound(noise) end) 

Here is a link to a video tutorial: https://youtu.be/UPtKeJmLmoA


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.