marcineg Posted November 15, 2017 Posted November 15, 2017 Hi, how to get all the binded keys? I want to write a function which will work just like guiSetInputMode "no_binds_when_editing" only in dx. My scripts: Spoiler and others
Moderators IIYAMA Posted November 15, 2017 Moderators Posted November 15, 2017 https://wiki.multitheftauto.com/wiki/GetBoundKeys Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Tails Posted November 15, 2017 Posted November 15, 2017 You can use "no_binds" as the argument and "allow_binds" to toggle binds back on you may also want to cancel the onClientKey event. Discord: its.tails
marcineg Posted November 16, 2017 Author Posted November 16, 2017 Quote Note: unbindKey will only work on binds that were added by the same resource local playerBinds = {} function controlBinds(bool) if not bool then for key,value in pairs(alfabetLacinski) do local cmds = getCommandsBoundToKey(key,"down") for k,cmd in pairs(cmds) do local bind = getBoundKeys(k) for l,j in pairs(bind) do table.insert(playerBinds,{key=l, state=j,cmd=k}) unbindKey(l) print("UNBIND: "..l) end end end else -- BIND end end I used toggleControl and setControlState to unbind the key, but it only unbinded the default bind eg chatbox. Player binds such as admin panel still etc. My scripts: Spoiler and others
Tails Posted November 16, 2017 Posted November 16, 2017 (edited) 1 hour ago, marcineg said: Player binds such as admin panel still etc. 22 hours ago, Tails said: you may also want to cancel the onClientKey event. Cancel this event addEventHandler("onClientKey", root, function() cancelEvent() end) Edited November 16, 2017 by Tails Discord: its.tails
marcineg Posted November 16, 2017 Author Posted November 16, 2017 If I do this, I will not be able to write in the edit box in dx. I'm using onClientCharacter, but it probably does not matter. My scripts: Spoiler and others
Tails Posted November 16, 2017 Posted November 16, 2017 You will be with onClientCharacter Discord: its.tails
marcineg Posted November 16, 2017 Author Posted November 16, 2017 How to restore bind's later? My scripts: Spoiler and others
Tails Posted November 16, 2017 Posted November 16, 2017 You could do something like this local inputEnabled = false addEventHandler("onClientKey", root, function() if (inputEnabled) then cancelEvent() end end) You can just toggle the inputEnabled var in your script 1 Discord: its.tails
marcineg Posted November 17, 2017 Author Posted November 17, 2017 Thanks for help! Close topic. My scripts: Spoiler and others
pa3ck Posted November 17, 2017 Posted November 17, 2017 You don't need to write your own function. You can use guiSetInputMode, it doesn't have to be a GUI if you use "no_binds" instead of "no_binds_when_editing". guiSetInputMode("no_binds") guiSetInputEnabled(true)
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