addCommandHandler
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function will attach a scripting function (handler) to a console command, so that whenever a player or administrator uses the command the function is called.
You can't use "check", "list", "test" and "help" as a command name.
Do NOT use the same name for your handler function as the command name, as this can lead to confusion if multiple handler functions are used. Use a name that describes your handler's purpose more specifically.
Syntax
bool addCommandHandler ( )Returns
- bool: value
Returns true if the command handler was added successfully, false otherwise.
Code Examples
Example 1:This example warps the local player to a random nearby location (useful for when a player gets stuck somewhere).
function escapeMe ( commandName ) local x, y, z = getElementPosition ( localPlayer ) --Get player's position setElementPosition ( localPlayer, x+(math.random(-10,10)), y+(math.random(-10,10)), z+(math.random(1,15)) ) --Move a player randomly to a nearby location. X is current x + a number between -10, 10 and so on.endaddCommandHandler ( "escape", escapeMe ) --When player types "/escape" in chatbox or "escape" in consoleSee Also
Input Functions
- addCommandHandler
- bindKey
- executeCommandHandler
- getAnalogControlState
- getBoundKeys
- getCommandHandlers
- getCommandsBoundToKey
- getFunctionsBoundToKey
- getKeyBoundToCommand
- getKeyBoundToFunction
- getKeyState
- isCapsLockEnabled
- isControlEnabled
- isKeyBound
- removeCommandHandler
- setAnalogControlState
- toggleAllControls
- toggleControl
- unbindKey
Input Events
- onClientCharacter
- onClientClick
- onClientCursorMove
- onClientDoubleClick
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientKey
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel
- onClientPaste