OnChatMessage: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(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| | ||
}} | }} | ||
This event is triggered when a player uses say, teamsay | 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 | string theMessage, resource / element theElement | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''theMessage:''' | *'''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== | ==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"> | ||
function onChatMessageHandler(theMessage, thePlayer) | function onChatMessageHandler(theMessage, thePlayer) | ||
outputDebugString(theMessage) | outputDebugString(theMessage) |
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).
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
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled