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 :)
F1 - [url]http://wiki.garrysmod.com/page/GM/ShowHelp[/url]
F2 - [url]http://wiki.garrysmod.com/page/GM/ShowTeam[/url]
F3 - [url]http://wiki.garrysmod.com/page/GM/ShowSpare1[/url]
F4 - [url]http://wiki.garrysmod.com/page/GM/ShowSpare2[/url]
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 : [url]http://wiki.garrysmod.com/page/input/IsKeyDown[/url] and here is a list with all the keys [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexa077.html[/url]
[QUOTE=BoowmanTech;42611511]You could use : [url]http://wiki.garrysmod.com/page/input/IsKeyDown[/url] and here is a list with all the keys [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexa077.html[/url][/QUOTE]
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 [url="http://wiki.garrysmod.com/page/GM/PlayerBindPress"]PlayerBindPress[/url] hook, or the [url="http://wiki.garrysmod.com/page/GM/KeyPress"]KeyPress[/url] and [url="http://wiki.garrysmod.com/page/GM/KeyRelease"]KeyRelease[/url] hooks which use the [url="http://wiki.garrysmod.com/page/Enums/IN"]IN_[/url] enums.
Sorry, you need to Log In to post a reply to this thread.