====== OnDisconnect hook callback function ======
OnDisconnect is called when a client sends the disconnect packet and is about to be disconnected from the server.

Note that this callback is not called if the client drops the connection or is kicked by the server.

FIXME There is no callback for "client destroying" that would be called in all circumstances.

===== Function signature =====
<code lua>
function OnDisconnect(Player, Reason)
</code>
Parameters:
| Player | [[API:cPlayer|cPlayer]] | The player disconnecting |
| Reason | string | The reason that the client has sent in the disconnect packet |

===== Return values =====
If the function returns false or no value, MCServer calls other plugins' callbacks for this event and finally broadcasts a disconnect message to the player's world. If the function returns true, no other plugins are called for this event and the disconnect message is not broadcast. In either case, the player is disconnected.

===== Register Callback =====
To register your plugin for a callback on this function use the hook [[api:plugin:hooks |HOOK_DISCONNECT]]
<code lua>
PluginManager = cPluginManager:GetPluginManager();
PluginManager:AddHook(Plugin, cPluginManager.HOOK_DISCONNECT);
</code>