The only way I've seen a client can manipulate the sounds it's asked to play by the server is by GM/EntityEmitSound, however, this only works for sounds that were called on the client via entity:EmitSound.
I've tried returning false inside the hook function (I had a print statement inside it, letting me know when returns were being ran), but no noticeable changes to the sounds be played were made. The one EmitSound I call is still heard, as are all gunshots.
So I'm looking for a way for a client to mute all sound local to itself. Any help is appreciated
GM/PlayerCanHearPlayersVoice
local plyToMute -- Assume Valid & Alive Player
local function foo(listener, talker)
if (listener == plyToMute) then
return false
end
end
hook.Add("PlayerCanHearPlayersVoice", "foo", foo)
I'm not sure if it works, but try to use RunConsoleCommand to set "volume" to 0.
Sadly that does not work anymore, or at least not in the pre-release or dev branch. It will be (or it already has been) added to the blocked ConCommand list.
SoundScapes can't be blocked by EntityEmitSound.
If you don't want any sounds in the game, it would require you deleting all env_soundscape entities on server launch.
On a side note:
I've tried to manipulate the soundscapes C-value, however it looks like the system caches the sounds and then refuse to update.
The only thing that seems to update is the debug tools description.
Aye, I was aware of the soundscapes problem. However, it's for a TTT weapon, and TTT maps aren't known for being super high-production with a bunch of soundscapes that I need to worry about.
The primary things I need to worry about are: gunshots, player voices, explosions, and general walking noises. I thought that hook would be enough for guns/explosions/footsteps.
This is already being ran to block player voice chat stuff.
Still looking for ideas. Anything possibly engine-specific could call?
Bump. Looking for suggestions. It seems what Garry's Mod provides isn't working properly, or isn't documented properly. If someone knows the source engine well enough, maybe I could circumvent GLua functions.
No way to mute all sounds, using the volume ConVar was the only way, which is (will be) no longer a working solution. However I think there should be a default function added to make a player deaf, which won't affect user settings, that way you can do no harm with it.
You could do the dirty method and that is to run stopsound every tick on the player. Not the most optimized option but it does mute everything including the in-game voicechat.
you could try using this one: it uses the stopsound command every tick while the Muted value or other value is on
local Muted = true
hook.Add("Think","MuteGame",function()
if Muted then
LocalPlayer():ConCommand("stopsound")
end
end)
By "I think there should be," are you saying there's plans for one to be implemented along with the removal of the ConVar solution? Or that you would hope one ships with it?
I'll give that a shot. It's quite a nasty work-around, but if it works... it works.
Just hoping there would be one
Damn, alright. I suppose it's more pertinent, then, that I make that other solution work.
Sorry, you need to Log In to post a reply to this thread.