onConsole
Client-side
Server-side
Shared
This event is triggered when a player types a message into his console. It is also triggered when entering '/' commands via the chatbox.
The event will not be triggered if the message can be processed by an existing command handler
Parameters
string theMessage
- theMessage: a string representing the message entered into the console.
Source
element: The source of this event is the player that entered the message in the console. This can be a player or the server console.
Code Examples
server
function input_Console ( text ) --when a player types in the console -- if it's an ingame player, if ( getElementType ( source ) == "player" ) then --split the command by spaces (ASCII 32) and get the first piece of text local command = gettok ( text, 1, 32 ) --if the first piece of text was "yo", if ( command == "yo" ) then --get the player's name local playerName = getPlayerName ( source ) -- get the action text by substracting the first three characters ("yo ") local actionText = string.sub ( text, 3 ) -- announce the yo command into the chatbox outputChatBox ( "* " .. playerName .. " " .. actionText, getRootElement(), 255, 255, 0 ) end endendaddEventHandler ( "onConsole", getRootElement(), input_Console ) -- add an event handler for onConsole