OnChatMessage: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Remove obsolete Requirements section)
 
(4 intermediate revisions by 3 users not shown)
Line 3: Line 3:
{{New feature/item|3.0120|1.2|3316|
{{New feature/item|3.0120|1.2|3316|
}}
}}
This event is triggered when a player uses say, teamsay, me successfully. Or when any message is output to chat using [[outputChatBox]] on the server side. It can be used to get the resource responsible for specific [[outputChatBox]] call via the second parameter.
This event is triggered when any message is output to chat using [[outputChatBox]] server-side (also when a player uses ''say'', ''teamsay'' or ''me'' successfully).
{{Note|It can be used to get the [[element]] responsible for a specific [[outputChatBox]] call via the second parameter.}}


==Parameters==  
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string theMessage, resource / element theElement
string theMessage, resource / element theElement
</syntaxhighlight>
</syntaxhighlight>
*'''theMessage:''' The text that was output to the chatbox
*'''theMessage:''' A [[string]] representing the text that was output to the chatbox.
*'''theElement:''' Player element if chatbox output was done via say, teamsay or me. Resource if it was done via [[outputChatBox]].
*'''theElement:''' A [[resource]] if it was done via [[outputChatBox]] or a [[player]] element if it was done via ''say'', ''teamsay'' or ''me''.


==Source==
==Source==
Line 23: Line 24:
addEventHandler("onChatMessage", root, onChatMessageHandler)
addEventHandler("onChatMessage", root, onChatMessageHandler)
</syntaxhighlight>
</syntaxhighlight>
==Requirements==
{{Requirements|1.1.1-9.03316|n/a|}}


{{See also/Server event|Server events}}
{{See also/Server event|Server events}}

Latest revision as of 15:33, 7 November 2024

This event is triggered when any message is output to chat using outputChatBox server-side (also when a player uses say, teamsay or me successfully).

[[{{{image}}}|link=|]] Note: It can be used to get the element responsible for a specific outputChatBox call via the second parameter.

Parameters

string theMessage, resource / element theElement
  • theMessage: A string representing the text that was output to the chatbox.
  • theElement: A resource if it was done via outputChatBox or a player element if it was done via say, teamsay or me.

Source

The source of this event is the root element.

Example

This example outputs all chat messages to debug view.

function onChatMessageHandler(theMessage, thePlayer)
	outputDebugString(theMessage)
end
addEventHandler("onChatMessage", root, onChatMessageHandler)

See Also

Server events


Event functions