Keybindings for a server.

Hi there.

So I’m looking for a way to bind keys serverside so users don’t have to bind a key for the jukebox themselves.


hook.Add( "Think", "BM_Clients_Key", function()
    if input.IsKeyDown( KEY_1 ) then
        RunConsoleCommand("use","3d_maneuver_gear_expert_c")
    elseif input.IsKeyDown( KEY_2 ) then
        RunConsoleCommand("use","weapon_muskeblue")
    elseif input.IsKeyDown( KEY_F ) then
        RunConsoleCommand("use","aot_flaregun")
    end
end )

I found this on the forums but, when I used it spammed the command.

Is there any way to make it so the command runs once when the user presses the key?

Thanks in advance.

GM/KeyPress

Thanks for the link. :smiley:

Still don’t quite understand how to implement it though :frowning:

hook.Add( “KeyPress”, “uniquehookidentifiernamehere”, function( ply, key )

end );

Ah. I get it now. Thanks for the extra help man. :slight_smile: