Sign in to follow this  
Oussema

Question Commands

Recommended Posts

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 

Share this post


Link to post

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)

 

  • Like 1

Share this post


Link to post
--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

 

  • Like 1

Share this post


Link to post
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 

Share this post


Link to post
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 !!

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.