GetKeyBoundToCommand: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Server client function}} This function allow you get first key binded to command. ==Syntax== <syntaxhighlight lang="lua"> string getKeyBoundToCommand( string command ) </syntaxhighlight> ===Required Ar...")
 
No edit summary
Line 21: Line 21:


addCommandHandler("bindedcommand",yourFunction)
addCommandHandler("bindedcommand",yourFunction)
function bindHandler()
function bindHandler()
   local bindedKey = getKeyBoundToCommand("bindedcommand") --get binded key
   local bindedKey = getKeyBoundToCommand("bindedcommand") --get binded key

Revision as of 08:52, 20 August 2011

This function allow you get first key binded to command.

Syntax

string getKeyBoundToCommand( string command )

Required Arguments

  • command: command what you need check.

Returns

Returns a string of first key binded to current command.

Example

Click to collapse [-]
Client
function yourFunction()
--your function here
end

addCommandHandler("bindedcommand",yourFunction)
function bindHandler()
  local bindedKey = getKeyBoundToCommand("bindedcommand") --get binded key
    if not bindedKey then
      bindedKey = "z"
      bindKey(bindedKey,"down","bindedcommand")  --if key is not exist then bind it by syntax 2
    end
  outputChatBox("Press '"..bindedKey.."' for do yourFunction",255,255,0,true) --after all done output it in chatbox
end
addEventHandler("onClientResourceStart", bindHandler)

See Also