executeCommandHandler
Client-side
Server-side
Shared
This page is incomplete! Help wanted!
Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.
This function will call all the attached functions of an existing console command, for a specified player.
Note
You can only execute commands created with addCommandHandler. You cannot execute MTA harcoded commands due to security reasons.
Note
Serverside commands can only be executed by the server. The same applies to the client side
Syntax
executeCommandHandler ( )Code Examples
server
This example defines a command handler for the commandcreatemarker(which creates a red marker at the caller's position). It then creates a second command handlercreatemarker2which will call the first one.
-- Define the function that will handle the 'createmarker' commandfunction consoleCreateMarker ( playerSource, commandName ) -- If a player triggered it (rather than the admin) then if ( playerSource ) then -- Get that player's position x, y, z = getElementPosition ( playerSource ) -- Create a marker at their position createMarker ( x, y, z, 0, "checkpoint", 255, 0, 0, 255 ) -- Output it in the chat box outputChatBox ( "You got a red marker", playerSource ) endend-- Add the function as a handler for the commandaddCommandHandler ( "createmarker", consoleCreateMarker )
-- Define a second console command that will just call the first.-- First define the functionfunction consoleCreateMarker2 ( playerSource, commandName ) -- re-route back to the original executeCommandHandler ( "createmarker", playerSource )end-- Then add it as a handler for the new console commandaddCommandHandler ( "createmarker2", consoleCreateMarker2 )See 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