Bonsai Posted August 25, 2014 Share Posted August 25, 2014 Hey Peeps, is there a way to get the commands that are bound to a key? I've only found a function to get to functions bound. But since its also possible to bind commands, there gotta be a way to get those too. Bonsai Link to comment
Bonsai Posted August 26, 2014 Author Share Posted August 26, 2014 C'mooooon, someone gotta know something Link to comment
Et-win Posted August 26, 2014 Share Posted August 26, 2014 Just addCommandHandler to the function that you bind. Please be silent if you have no idea where he is talking about, because he wants to get all commands that are binded to what key. Link to comment
Et-win Posted August 26, 2014 Share Posted August 26, 2014 just pointing will be useful than provoking me. Hehe, true. Sorry. Link to comment
Mr_Moose Posted August 26, 2014 Share Posted August 26, 2014 Well as you said these seems to be for functions: getFunctionsBoundToKey getKeyBoundToFunction But since they return a table (with strings I assume) it might work for bound commands as well, try the wiki example if you haven't done it yet and see what it outputs. Admin panel for example (default key: 'P') can be accessed by the command '/admin' as well, so if this works you should be able to see that in the output. function output() outputChatBox("Hi") end bindKey("f2","down",output) local keyTable = { "mouse1", "mouse2", "mouse3", "mouse4", "mouse5", "mouse_wheel_up", "mouse_wheel_down", "arrow_l", "arrow_u", "arrow_r", "arrow_d", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "num_0", "num_1", "num_2", "num_3", "num_4", "num_5", "num_6", "num_7", "num_8", "num_9", "num_mul", "num_add", "num_sep", "num_sub", "num_div", "num_dec", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "backspace", "tab", "lalt", "ralt", "enter", "space", "pgup", "pgdn", "end", "home", "insert", "delete", "lshift", "rshift", "lctrl", "rctrl", "[", "]", "pause", "capslock", "scroll", ";", ",", "-", ".", "/", "#", "\\", "=" } addCommandHandler("gakf",function() for _,i in ipairs(keyTable)do --loop through keyTable for _,v in ipairs(getFunctionsBoundToKey(i))do --loop through the key bounded functions outputChatBox(i..":"..v) --output the keyname and the function bound to it end end end) Link to comment
Salem Posted December 17, 2017 Share Posted December 17, 2017 (edited) Do you know how to get names of functions. There are numbers like objects data. The letter keys are not returned. I mean, I need a list like in menu -> binds. This function is promising but doesn't work for me. I mean, I'm asking because want to use something like this: function playerPressedKey( button, press ) local boundKey = getKeyBoundToFunction( 'horn' ); if button == boundKey then if ( press ) then ACTION = false outputDebugString( "You pressed the "..button.." key!" ) end end end addEventHandler( "onClientKey", root, playerPressedKey ) which should work that way - I use horn to speed up ped's slow walking on the street. But don't know where's horn binded. Edited December 17, 2017 by Salem Link to comment
Moderators IIYAMA Posted December 17, 2017 Moderators Share Posted December 17, 2017 (edited) https://wiki.multitheftauto.com/wiki/GetCommandsBoundToKey https://wiki.multitheftauto.com/wiki/GetKeyBoundToCommand Damn, why I am posting on a very old topic!!! No..no... @Salem... Edited December 17, 2017 by IIYAMA 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now