- Documentation
- Shared functions
- executeCommandHandler
Function
executeCommandHandler
Runs a command registered with addCommandHandler as if a player typed it. On the server you pass a player (or nil) and the arguments: a single string is split into words like in chat. On the client it runs client commands.
Syntax
Server
bool executeCommandHandler(string commandName, player thePlayer [, string args])Client
bool executeCommandHandler(string commandName [, string args])Arguments
commandNamestring- Command name.
thePlayerplayer- The player who "typed" the command (server only).
argsstring, optional- Command arguments.
Returns
true if the command exists and was run.
Example
addEventHandler("onPlayerJoin", root, function()
executeCommandHandler("pomoc", source)
end)
See also
addCommandHandlerRegisters a chat and console command (e.g./car). When a player types it, the function is called. On the server the function gets the player, the command name and the following words as separate arguments; on the client the command name and the words. One command can have several functions, also from different resources. The command goes away with the resource that added it.executeCommandSends a command to the server as if the player typed it in chat (without the leading slash).