Oussema Posted April 3, 2019 Share Posted April 3, 2019 Hi , is there way to disable bind "key" "command" from console or Chat ! i'll try to explain more , i have inventory system which have command /useitem (itemname) and players can bind the command and i won't them bind it sorry Link to comment
Moderators Patrick Posted April 3, 2019 Moderators Share Posted April 3, 2019 I think you can't make difference between bind and command use. (not sure) But you can block function use, when command is binded to any key. -- CLIENT ONLY function useitem(cmd) if not getKeyBoundToCommand(cmd) then outputChatBox("Item used!") else outputChatBox("Unbind this command first!") end end addCommandHandler("useitem", useitem) 1 Link to comment
Mahlukat Posted April 3, 2019 Share Posted April 3, 2019 --client-side yasaklilar = { --"command", "useitem", "say", ... } addEventHandler("onClientKey", root,function(button, press) local komut = getBinds(button) if komut and press then if not guiGetInputEnabled() and not isChatBoxInputActive() then cancelEvent() outputChatBox("This button has an inappropriate command. To remove: #FFFFFF/unbind #CC0000"..button.." #FFFFFF"..komut, 255,0,0, true) end end end) function getBinds(buton) for i,v in pairs(yasaklilar) do local butons = getBoundKeys ( v ) if type(butons) ~= "boolean" and butons[buton] then return v end end return false end 1 Link to comment
Oussema Posted April 4, 2019 Author Share Posted April 4, 2019 On 03/04/2019 at 11:04, stPatrick said: I think you can't make difference between bind and command use. (not sure) But you can block function use, when command is binded to any key. -- CLIENT ONLY function useitem(cmd) if not getKeyBoundToCommand(cmd) then outputChatBox("Item used!") else outputChatBox("Unbind this command first!") end end addCommandHandler("useitem", useitem) On 03/04/2019 at 11:24, Mahlukat said: --client-side yasaklilar = { --"command", "useitem", "say", ... } addEventHandler("onClientKey", root,function(button, press) local komut = getBinds(button) if komut and press then if not guiGetInputEnabled() and not isChatBoxInputActive() then cancelEvent() outputChatBox("This button has an inappropriate command. To remove: #FFFFFF/unbind #CC0000"..button.." #FFFFFF"..komut, 255,0,0, true) end end end) function getBinds(buton) for i,v in pairs(yasaklilar) do local butons = getBoundKeys ( v ) if type(butons) ~= "boolean" and butons[buton] then return v end end return false end Thanks both Link to comment
Oussema Posted April 5, 2019 Author Share Posted April 5, 2019 16 hours ago, Oussema said: getKeyBoundToCommand 16 hours ago, Oussema said: getBoundKeys i can get command args with these functions ? for example /bind a useitem itemName and when i use these function i can get the key & the item name !! 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