Jump to content

bindKey, unbindKey, isKeyBound


CITMartin

Recommended Posts

This function bindKey, unbindKey and isKeyBound have very errors when i use it with the option 2.

 
  1. bool bindKey ( player thePlayer, string key, string keyState, string commandName, [ string arguments ] )

Example script:

 

PLS, SOMEONE OF DEVELOPER OF MTA CHECK THIS

 

function addBindServer (player, commandName, theKey, theNewCommandToAddBind)
	local arguments = "1 2 3 4"
	local theEK = bindKey (player, theKey, "down", theNewCommandToAddBind, arguments)
	
	if theEK == true then
		outputChatBox("Bind created: true")
	else
		outputChatBox("Bind created: false")
	end
	
	if isKeyBound (player, theKey) then
		outputChatBox("isKeyBound: true")
	else
		outputChatBox("isKeyBound: false")
	end
	
end
addCommandHandler("addBind", addBindServer)

function removeBindServer (player, commandName, theKey)

	local tableOfData = getFunctionsBoundToKey ( player , theKey )
	outputChatBox ("Number of Functions to key "..theKey..": "..#tableOfData)
	for a, z in ipairs(tableOfData) do
		if unbindKey (player, theKey, "down", z) then
			outputChatBox("unbindKey: true")
		else
			outputChatBox("unbindKey: false")
		end
	end
	
	if unbindKey (player, theKey) then
		outputChatBox("true")
	else
		outputChatBox("false")
	end
	
end
addCommandHandler("removeBind", removeBindServer)

function testingFunction (player, commandName, arg1, arg2, arg3, arg4)
	outputChatBox(arg1)
	outputChatBox(arg2)
	outputChatBox(arg3)
	outputChatBox(arg4)
end
addCommandHandler("testing", testingFunction)

 

 

DATA RETURN

 

Bind created: true
isKeyBound: false
Number of Functions to key m: 0
false

 

Link to comment
2 hours ago, MIKI785 said:

There's nothing wrong with those functions, you're binding it to a command, not a function.

if isKeyBound (player, theKey) then

When i am creating the bind, isKeyBound must be equal to true, if this is false is wrong.

 

the function unbindKey using a commandName as an argument is wrong.

 

Pls some developer mta check this.

Link to comment
  • Recently Browsing   0 members

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