DCS hook onPlayerTrySendChat

From DCS World Wiki - Hoggitworld.com

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.

IMPORTANT: If any value is returned with this function then any other callback that uses it will be ignored. If no choice is to be made, then do NOT return any value.

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 ""
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