OnChatMessage: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(7 intermediate revisions by 6 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| | ||
}} | }} | ||
This event is triggered when a player uses say, teamsay, me successfully. Or when any message is output to chat using [[outputChatBox]]. It can be used to get the resource responsible for specific [[outputChatBox]] call via the second parameter. | 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. | ||
==Parameters== | ==Parameters== | ||
Line 10: | Line 9: | ||
string theMessage, resource / element theElement | string theMessage, resource / element theElement | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''theMessage:''' | *'''theMessage:''' a [[string]] representing the text that was output to the chatbox. | ||
*'''theElement:''' | *'''theElement:''' a [[player]] element if chatbox output was done via ''say'', ''teamsay'' or ''me''. [[Resource]] if it was done via [[outputChatBox]]. | ||
==Source== | ==Source== | ||
Line 19: | Line 18: | ||
This example outputs all chat messages to debug view. | This example outputs all chat messages to debug view. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onChatMessageHandler(theMessage, thePlayer) | function onChatMessageHandler(theMessage, thePlayer) | ||
outputDebugString(theMessage) | outputDebugString(theMessage) |
Revision as of 03:05, 27 September 2018
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.
Parameters
string theMessage, resource / element theElement
- theMessage: a string representing the text that was output to the chatbox.
- theElement: a player element if chatbox output was done via say, teamsay or me. Resource if it was done via outputChatBox.
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
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getCancelReason
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- triggerClientEvent
- triggerLatentClientEvent
- wasEventCancelled