F4 stopsound command for users

Ok so on the ttt server that i play on, there are a lot of songs and sounds being played and it can be offputting and stop you from hearing important things so i want to include a feature to allow players to use the “stopsound” command by pressing F4. This is what i have at the moment, but it doesn’t do the job, anyone point me in the right direction?

function StopAllSound(ply, key)
if key == KEY_F4 then
hook.Add( “KeyPress”, “KeyPressedHook”, StopAllSound )

I haven’t programmed in Glua for a long time, but as far as I remember, this should work.

function GM:ShowSpare2( ply ) – Default is F4

ply:ConCommand( "stopsound" )


That won’t work because stopsound is clientside and its a console command. You can use GM:ShowSpare2 but you need to have a net message that sends the command to the client.

function GM:ShowSpare2( ply )

Should do the trick.

Great this worked :slight_smile: