OnClientChatMessage: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 15: Line 15:
The [[event system#Event source|source]] of this event is the root element.
The [[event system#Event source|source]] of this event is the root element.
==Example==
==Example==
This example doesn't output anything to chatbox if it consists only of numbers
<syntaxhighlight lang="lua">
[lua]
function onClientChatMessageHandler(text)
if string.match(text,"%d+") --[[string.match searches for pattern "%d+", means decimals]] == text then -- if string.match and text itself are the same
cancelEvent() -- don't output it
end
end
</syntaxhighlight>


==See Also==
==See Also==

Revision as of 10:32, 16 May 2009

This event is triggered when any text is output to chatbox, including MTA's hardcoded messages.

Parameters

string text, int r, int g, int b
  • text: The text that was output to chatbox
  • r: The amount of red in the color of the text.
  • g: The amount of green in the color of the text.
  • b: The amount of blue in the color of the text.

Source

The source of this event is the root element.

Example

This example doesn't output anything to chatbox if it consists only of numbers

[lua]
function onClientChatMessageHandler(text)
	if string.match(text,"%d+") --[[string.match searches for pattern "%d+", means decimals]] == text then -- if string.match and text itself are the same
		cancelEvent() -- don't output it
	end
end

See Also

Client other events


Client event functions