OnClientConsole: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (ouputChatBox had a player arg (only required server-side).)
(Replace to predefined variable.)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Incomplete Event]]
{{Client event}}
{{Client event}}
__NOTOC__  
__NOTOC__  
This event is triggered when the local player enters text in the console. Note that, if you want to add custom console commands, it is easier to the [[addCommandHandler]] function.
This event is triggered when the local player enters text in the console. Note that, if you want to add custom console commands, it is easier to use the [[addCommandHandler]] function.


==Parameters==
==Parameters==
Line 14: Line 13:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function consoleCheck(text)
function consoleCheck(text)
outputChatBox("You entered into the console: "..text,255,255,0)
outputChatBox("You entered into the console: "..text, 255, 255, 0)
end
end
addEventHandler("onClientConsole",getLocalPlayer(),consoleCheck)
addEventHandler("onClientConsole", localPlayer, consoleCheck)
</syntaxhighlight>
</syntaxhighlight>



Latest revision as of 15:44, 27 February 2021

This event is triggered when the local player enters text in the console. Note that, if you want to add custom console commands, it is easier to use the addCommandHandler function.

Parameters

string text
  • text: the text line that was entered.

Example

This example outputs any text you input into the console.

function consoleCheck(text)
	outputChatBox("You entered into the console: "..text, 255, 255, 0)
end
addEventHandler("onClientConsole", localPlayer, consoleCheck)

See Also

Other client events


Client event functions