Server Side Key bindings?

I attempted to bind weapons to certain keys in config_default.cfg to be used on my server.


bind "1" "slot1"
bind "2" "slot2"
bind "f" "impulse 100"

Switched to


bind "1" "use 3d_maneuver_gear_expert_c;use 3d_maneuver_gear_c"
bind "2" "use weapon_muskeblue"
bind "f" "use aot_flaregun"

I then restarted the server and it didn’t work.
I then proceeded to add “exec config_default.cfg” to server.cfg, that didn’t work either
I then deleted that line of code and opened up autoexec.cfg and put “config_default.cfg” and that didn’t work.

So either server side bindings don’t work or I am just missing something crucial.

I binded them in-game in my console and those commands work, but sadly my idea to do it in config_default.cfg did not.

Any help would be appreciated.

config_default.cfg is serversided it will only execute the commands on your server and not on the clients.

I don’t think you should use the bind command for that as it will stay like that on player’s game, you should use Lua.

Ok so don’t attempt to bind it server-side and instead use Lua. How would one do that? Also where would it be placed? Autorun?

You could use IsKeyDown and RunConsoleCommand.

[editline]19th October 2014[/editline]

“autorun/client”


hook.Add("PlayerKeyPress","BindWeapons",function(pl,key)
	if key == KEY_1 then Player:SetActiveWeapon( " 3d_maneuver_gear_expert_c;3d_maneuver_gear_c" ) else
	if key == KEY_2 then Player:SetActiveWeapon( "weapon_muskeblue" ) else
	if key == KEY_F then Player:SetActiveWeapon( "aot_flaregun" )
end
	end
		end
			end)

Would that work? Also this is in autorun/client.

Player should be pl and SetActiveWeapon should be Give unless in loadout.



hook.Add( "Think", "BM_Clients_Key", function()
    if input.IsKeyDown( KEY_1 ) then
        RunConsoleCommand("use <weapon>")
    elseif input.IsKeyDown( KEY_2 ) then
        RunConsoleCommand("use <weapon>")
    end
end )


Goes in ‘autorun/client’


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 )

It now works. Thanks for this Starfox.