Binds

Im really noob at LUA but i need to know how to bind a key to open new addon. Any Help

could really help if you could make me a quick template :slight_smile:

F1 - http://wiki.garrysmod.com/page/GM/ShowHelp
F2 - http://wiki.garrysmod.com/page/GM/ShowTeam
F3 - http://wiki.garrysmod.com/page/GM/ShowSpare1
F4 - http://wiki.garrysmod.com/page/GM/ShowSpare2

These are hooks. Any functions hooked to them will be run when certain events happen in-game.
These hooks all determine what happens when someone presses one of these buttons.
The server handles these, so they have to be placed in server-side files, or autorun in the server folder.

Simple example:
[lua]hook.Add( “ShowSpare1”, “YourHookName”, function( ply )
ply:ConCommand( “ulx menu” )
end )[/lua]

These hooks all return the player that pressed the key, so you make them run the console command to open the ULX menu (as an example). Most addons should have a console command like this.

Thanks for that but is there anyway to add a different key like F5, F6 OR F7?

You could use : http://wiki.garrysmod.com/page/input/IsKeyDown and here is a list with all the keys http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexa077.html

In that case you’re better off using input.WasKeyPressed(), input.WasKeyReleased() or input.WasKeyTyped()

I’d recommend against using a specific key, unless you want to annoy users.

If the hooks Internet1001 gave you aren’t enough, you could also use the PlayerBindPress hook, or the KeyPress and KeyRelease hooks which use the IN_ enums.