Revision Difference
gameevent/player_disconnect#549546
<cat>gameevent</cat>
<title>player_disconnect</title>
<structure>
<realm>Shared and Menu</realm>
<description>
Called when a player disconnects from the server.
<note>
This is also called when a player cancels connecting to the server.
This is not called clientside for the local player or in single-player.
This is not called clientside for the local player or in single-player.
When this gameevent is called, the player will be NULL!. so you cannot use `Player(data.userid)`!⤶
</note>
</description>
<fields>
<item type="number" name="bot">0 if the player isn't a bot, 1 if they are.</item>
<item type="string" name="networkid">The SteamID the player has. Will be `BOT` for bots and `STEAM_0:0:0` in single-player.</item>
<item type="string" name="name">The <page text="name">Player:Nick</page> the player has.</item>
<item type="number" name="userid">The <page text="UserID">Player:UserID</page> the player has.</item>
<item type="string" name="reason">The disconnect reason.</item>
</fields>
</structure>
# Examples
<example>
<description>This is a basic template with the purpose of including all arguments / table variables to make it easily known which values can be accessed.</description>
<code>
gameevent.Listen( "player_disconnect" )
hook.Add( "player_disconnect", "player_disconnect_example", function( data )
local name = data.name // Same as Player:Nick()
local steamid = data.networkid // Same as Player:SteamID()
local id = data.userid // Same as Player:UserID()
local bot = data.bot // Same as Player:IsBot()
local reason = data.reason // Text reason for disconnected such as "Kicked by console!", "Timed out!", etc...
// Player has disconnected - this is more reliable than PlayerDisconnect
end )
</code>
</example>