Jump to content

Question Commands


Oussema

Recommended Posts

  • Moderators

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...