OnClientChatMessage

From Multi Theft Auto: Wiki
Revision as of 14:44, 7 October 2021 by Quiret (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.
  • messageType: The type of message as a number.
  • 0: normal message
  • 1: action message (/me)
  • 2: team message
  • 3: private message
  • 4: internal message

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