OnClientChatMessage: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 11: Line 11:
*'''g:''' The amount of green 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.
*'''b:''' The amount of blue in the color of the text.
{{New items|3.0159|1.5.8|
{{Added feature/item|3.0160|1.5.9|1.5.8|20912|
*'''messageType:''' The type of message as a number.
*'''messageType:''' The type of message as a number.
{{Message Types}}
{{Message Types}}
|20912}}
}}
This function is used to change the loop option of the [[sound]] [[element]].
This function is used to change the loop option of the [[sound]] [[element]].



Revision as of 13:24, 23 September 2021

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

Parameters

string text, int r, int g, int b, int messageType
  • 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.

20912 This function is used to change the loop option of the sound element.

Source

The source of this event is either a player element or the root element.

Cancel effect

If this event is canceled, the game's chat system won't deliver the posts. You may use outputChatBox to send the messages then.

Example

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

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
addEventHandler("onClientChatMessage", root, onClientChatMessageHandler)

See Also

Client other events


Client event functions