OnConsole: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
[[Category:Incomplete Event]]
__NOTOC__  
__NOTOC__  
This event is blahblah and is used for blahblah.
This event is triggered when a player types any message into the console


==Syntax==  
==Syntax==  
Line 8: Line 6:
void onConsole ( string message )           
void onConsole ( string message )           
</syntaxhighlight>  
</syntaxhighlight>  
==Variables==
*'''message''': A string representing the message typed into the console


==Example==  
==Example==  
This example does...
This example adds the /me command into the script. For example, if a player called Bob types "me likes pie" in console, it will display "* Bob likes pie" in the chatbox.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function onConsole ( text )
blabhalbalhb --abababa
if ( getElementType ( source ) == "player" ) then
--This line does this...
    command = gettok ( text, 1, 32 )
mooo
if ( command == "me" ) then
local playername = getClientName ( source )
local textage = string.gsub ( text, "me", "", 1 )
outputChatBox ( "* " .. playername .. "" .. textage, root, 255, 255, 0 )
end
end
end
</syntaxhighlight>
</syntaxhighlight>
==See Also==
[[Split]]

Revision as of 00:01, 18 November 2006

This event is triggered when a player types any message into the console

Syntax

void onConsole ( string message )          

Variables

  • message: A string representing the message typed into the console

Example

This example adds the /me command into the script. For example, if a player called Bob types "me likes pie" in console, it will display "* Bob likes pie" in the chatbox.

function onConsole ( text )
	if ( getElementType ( source ) == "player" ) then
    command = gettok ( text, 1, 32 ) 
	if ( command == "me" ) then
		local playername = getClientName ( source )
		local textage = string.gsub ( text, "me", "", 1 )
		outputChatBox ( "* " .. playername .. "" .. textage, root, 255, 255, 0 )
		end
	end
end

See Also

Split