Garry's Mod Wiki

Revision Difference

gameevent/OnRequestFullUpdate#548571

<cat>gameevent</cat>⤶ <title>OnRequestFullUpdate</title>⤶ ⤶ <structure>⤶ <realm>Shared</realm>⤶ <description>⤶ Called when a player requests a full update from the server.⤶ Called Clientside when the Update is received.⤶ ⤶ <note>When this event is called <page>net</page> messages will be reliably received by the client.</note>⤶ </description>⤶ <fields>⤶ <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="number" name="index">The <page text="EntIndex">Entity:EntIndex</page> of the player, minus one.</item>⤶ </fields>⤶ </structure>⤶ ⤶ # Examples⤶ <example>⤶ <description>Early Networking Example</description>⤶ <code>⤶ local pending_players = {}⤶ ⤶ hook.Add( "PlayerInitialSpawn", "EarlyNetworking_Example", function( ply ) ⤶ pending_players[ ply:UserID() ] = true⤶ end )⤶ ⤶ gameevent.Listen( "OnRequestFullUpdate" )⤶ hook.Add( "OnRequestFullUpdate", "OnRequestFullUpdate_example", function( data )⤶ local index = data.index // Same as Entity:EntIndex() minus one⤶ ⤶ pending_players[ index ] = nil⤶ ⤶ // Some networking here⤶ ⤶ end )⤶ </code>⤶ </example>⤶ ⤶ <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( "OnRequestFullUpdate" )⤶ hook.Add( "OnRequestFullUpdate", "OnRequestFullUpdate_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 index = data.index // Same as Entity:EntIndex() minus one⤶ ⤶ // Called when a player requests a full update from the server.⤶ ⤶ end )⤶ </code>⤶ </example>