M MY Multiplayer: Wiki
Side
Kind

executeCommandHandler

Server

Runs the handlers server scripts registered for a command, as if the player had typed it.

Also exists on the client, with its own implementation: executeCommandHandler

bool executeCommandHandler(string commandName, any ... [, element thePlayer = console])

Parameters

NameTypeDescription
commandNamestringThe command's name.
thePlayerelementThe element passed to the handlers as whoever typed it: a player or the console. Pass nil to skip it.default console
...anyArguments passed to the handlers, each turned into a string.

Returns

true if a running resource handled the command, false if none did.

It runs every resource's handlers, not only this one's. onPlayerCommand does not fire.

Example

addEventHandler("onPlayerJoin", root, function()
    executeCommandHandler("spawn", source)
end)

See also