Difference between revisions of "DCS hook onPlayerTrySendChat"

From DCS World Wiki - Hoggitworld.com
(Created page with "{{Template:DCS_hooks_callbacks |fName= onPlayerTrySendChat |vNum= 2.5.0 |par1= hook |par2= |par3= |par4= |desc= Occurs when a player attempts to...")
 
(No difference)

Latest revision as of 00:39, 15 May 2021


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