alcholistu Posted February 6, 2014 Share Posted February 6, 2014 function checkBinds() if getBoundKeys("reconnect") or getBoundKeys("disconnect") then -- if has reconnect and disconnect bound outputChatBox ("You musn't have this key bound.", 255, 0, 0) -- unbindKey ( source, getBoundKeys ("reconnect") , "both" ) -- unbind key unbindKey ( source, getBoundKeys ("disconnect") , "both" ) -- unbind key end end setTimer(checkBinds, 60000, 0) Show the Warning but it doesn't unbind the keys... Source is the player who has the key bound ? Link to comment
myonlake Posted February 6, 2014 Share Posted February 6, 2014 getBoundKeys returns an array, which means you have to loop through the array and remove each one in it. local illegalHandlers = { "reconnect", "disconnect" } function checkBinds( ) local wasWarned for _, handler in ipairs( illegalHandlers ) do if ( getBoundKeys( handler ) ) then for key, state in pairs( getBoundKeys( handler ) ) do unbindKey( key, state, handler ) end if ( not wasWarned ) then outputChatBox( "You mustn't have this key bound.", 255, 0, 0, false ) wasWarned = true end end end end setTimer( checkBinds, 60000, 0 ) Note, that this is client-side code, so make sure to have the script set to client-side in meta.xml configuration file. EDIT: Copy the code again. Been scripting other languages all day long so I went crazy with the brackets, heh. Link to comment
alcholistu Posted February 6, 2014 Author Share Posted February 6, 2014 getBoundKeys returns an array, which means you have to loop through the array and remove each one in it. local illegalHandlers = { "reconnect", "disconnect" } function checkBinds( ) local wasWarned for _, handler in ipairs( illegalHandlers ) do if ( getBoundKeys( handler ) ) then for key, state in pairs( getBoundKeys( handler ) ) do unbindKey( key, state, handler ) end if ( not wasWarned ) then outputChatBox( "You mustn't have this key bound.", 255, 0, 0, false ) wasWarned = true end end end end setTimer( checkBinds, 60000, 0 ) Note, that this is client-side code, so make sure to have the script set to client-side in meta.xml configuration file. EDIT: Copy the code again. Been scripting other languages all day long so I went crazy with the brackets, heh. It unbinds... Only send the message (( nothing in debugscript O_o )) Link to comment
myonlake Posted February 6, 2014 Share Posted February 6, 2014 I feel like you cannot unbind MTA internal commands from keys. Link to comment
Saml1er Posted February 7, 2014 Share Posted February 7, 2014 (edited) Why don't you do it in this way? "command.reconnect" access="false" /> Simply add this line in default in acl. Edited February 7, 2014 by Guest Link to comment
myonlake Posted February 7, 2014 Share Posted February 7, 2014 No. You cannot manage MTA internal commands, because that would be a big security issue. 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