M MY Multiplayer: Wiki
Side
Kind

onPlayerCommand

ServerEventCancellable

Fired when a player sends a command to the server, before it runs. Cancelling the event stops the command.

addEventHandler("onPlayerCommand", root, function(string command) … end)

Handler parameters

NameTypeDescription
commandstringThe command's name, without its arguments.

Source

The player who sent the command.

The client sends the server the commands no client script handled and the ones only the server runs, such as the resource commands. executeCommandHandler does not fire this event.

Example

local lastCommand = {}

addEventHandler("onPlayerCommand", root, function(command)
    local now = getTickCount()
    if lastCommand[source] and now - lastCommand[source] < 500 then
        cancelEvent()
        return
    end
    lastCommand[source] = now
end)

See also