• F4 stopsound command for users
    4 replies, posted
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? [LUA] function StopAllSound(ply, key) if key == KEY_F4 then ply:RunConsoleCommand("stopsound") end end hook.Add( "KeyPress", "KeyPressedHook", StopAllSound ) [/LUA]
I haven't programmed in Glua for a long time, but as far as I remember, this should work. [lua] function GM:ShowSpare2( ply ) -- Default is F4 ply:ConCommand( "stopsound" ) end [/lua]
[QUOTE=McDunkable;40348827]I haven't programmed in Glua for a long time, but as far as I remember, this should work. [lua] function GM:ShowSpare2( ply ) -- Default is F4 ply:ConCommand( "stopsound" ) end [/lua][/QUOTE] 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.
[code]function GM:ShowSpare2( ply ) ply:SendLua([[RunConsoleCommand("stopsound")]]) end [/code] Should do the trick.
Great this worked :)
Sorry, you need to Log In to post a reply to this thread.