OnChatMessage: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Server event}} __NOTOC__ {{New feature|3.0120|1.2| '''Available only in MTA SA 1.2 and onwards''' }} This event is triggered when a player uses say, teamsay, me successfully. ...")
 
No edit summary
 
(13 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{Server event}}
{{Server event}}
__NOTOC__  
__NOTOC__  
{{New feature|3.0120|1.2|
{{New feature/item|3.0120|1.2|3316|
'''Available only in MTA SA 1.2 and onwards'''
}}
}}
This event is triggered when a player uses say, teamsay, me successfully. Or when any message is sent to a player using [[outputChatBox]].
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, element thePlayer
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.
*'''thePlayer:''' The player who triggered the event (Needs checking by developer - thePlayer for me was not any element)
*'''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 19: Line 19:
This example outputs all chat messages to debug view.
This example outputs all chat messages to debug view.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
[lua]
function onChatMessageHandler(theMessage, thePlayer)
function onChatMessageHandler(theMessage, thePlayer)
outputDebugString(theMessage)
outputDebugString(theMessage)
Line 26: Line 25:
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==Requirements==
{{Requirements|1.1.1-9.03316|n/a|}}


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

Latest revision as of 16:58, 27 November 2021

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)

Requirements

Minimum server version 1.1.1-9.03316
Minimum client version n/a

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.1.1-9.03316" />

See Also

Server events


Event functions