Envrioment: | Server | ||
Function: | onPlayerTrySendChat | Added with: 2.5.0 | |
Member Of: | hook | ||
Syntax: | nothing hook.onPlayerTrySendChat(number playerId, string message, boolean all ) | ||
Description: | Occurs when a player attempts to send a chat message. This function can be used to suppress or modify the message from appearing. For example chat commands can be created for admins by checking who sent the message and doing an action based on that.
playerId is who sent the message message is a string of what they typed. all is a boolean if the message is to all.
| ||
Return Value: | nothing | ||
Return Actions: | Value 1: string
Filtered message "" An empty string. If empty the message will not be sent. | ||
Examples: | Replaces any occurrence of the word "hockey" with "Go Avs Go" in a chat message. Additionally if someone tries to say "Detroit Red Wings" then the message will be suppressed.
function myCall.onPlayerTrySendChat(id, msg, all) if string.gsub(msg, "hockey") then return "Go Avs Go" elseif string.find("Detroit Red Wings") then return "" end end | ||
Related Functions: | List of Callbacks: onMissionLoadBegin, onMissionLoadProgress, onMissionLoadEnd, onSimulationStart, onSimulationStop, onSimulationFrame, onSimulationPause, onSimulationResume, onGameEvent, onNetConnect, onNetMissionChanged, onNetConnect, onNetDisconnect, onPlayerConnect, onPlayerDisconnect, onPlayerStart, onPlayerStop, onPlayerChangeSlot, onPlayerTryConnect, onPlayerTrySendChat, onPlayerTryChangeSlot | ||
Notes: |