AfuSensi Posted August 14, 2014 Share Posted August 14, 2014 Hey, I'm trying to make an bind system for my script, it binds a key to a chatbox command. So for purpose of testing, i made a simple script to showcase what's going wrong. bindKeyTable = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"} function bindTheKeys() for f, u in pairs(bindKeyTable) do bindKey(tostring(u), "down", "chatbox", tostring(f) ) end end addEventHandler("onClientResourceStart", resourceRoot, bindTheKeys) function UnbindThem(n, whatnumber) outputChatBox("Unbound "..whatnumber) unbindKey( tostring(whatnumber), "down", "chatbox" ) end addCommandHandler( "unbindme", UnbindThem) -- usage, /unbindme (number/key) As you can see, it creates chatbox binds from number 1 to 10. And adds a command to unbind a cerntain key. But if i use the command, it deletes all binds for the chatbox made by this resource. Is this wrong? unbindKey( tostring(whatnumber), "down", "chatbox" ) Thanks. Link to comment
tosfera Posted August 14, 2014 Share Posted August 14, 2014 Your mistake is here: for f, u in pairs(bindKeyTable) do f, u indicates that it's an ipairs which is not the case. Link to comment
AfuSensi Posted August 14, 2014 Author Share Posted August 14, 2014 Your mistake is here: for f, u in pairs(bindKeyTable) do f, u indicates that it's an ipairs which is not the case. This is actually not the problem, and wasnt really my question. It does not matter in what order the keys bind, only if they bind. The problem is if i unbind 1 bind, function UnbindThem(n, whatnumber) outputChatBox("Unbound "..whatnumber) unbindKey( tostring(whatnumber), "down", "chatbox" ) end addCommandHandler( "unbindme", UnbindThem) -- usage, /unbindme (number/key) It removes all binds bound the the chatbox control. This might be an MTA bug, thats why i created this simple script for people to test or if i have the syntax for unbindKey wrong in this case. If you want to test it on your own way, make 2 binds to the control "chatbox", and then unbind one of them, Both will be gone. Link to comment
AfuSensi Posted August 15, 2014 Author Share Posted August 15, 2014 https://bugs.multitheftauto.com/view.php?id=8459 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