====== OnChat hook callback function ======
A plugin may implement an OnChat() function and register it as a [[API:Plugin:Hooks|Hook]] to process chat messages from the players. The function is then called for every in-game message sent from any player.
Note that commands are handled separately using a [[API:CommandFramework|command framework API]].

===== Function signature =====
<code lua>
function OnChat(Player, Message)
</code>
Parameters:
| Player | cPlayer | The player that has sent the message |
| Message | string | The message |

===== Return values =====
The plugin may return 2 values. The first is a boolean specifying whether the hook handling is to be stopped or not. If it is false, the message is broadcast to all players in the world.
If it is true, no message is broadcast and no further action is taken.

The second value specifies the message to broadcast. This way, plugins may modify the message. If the second value is not provided, the original message is used.

===== Registering the callback =====
To register your plugin to receive a callback through this function, use the hook [[api:plugin:hooks|HOOK_CHAT]]
<code lua>
PluginManager = cPluginManager:GetPluginManager()
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT)
</code>