Garry's Mod Wiki

Revision Difference

GM:PlayerConnect#511096

<function name="PlayerConnect" parent="GM" type="hook">⤶ <ishook>yes</ishook>⤶ <description>⤶ Executes when a player connects to the server. Called before the player has been assigned a [UserID](/gmod/Player/UserID) and entity. See the [player_connect gameevent](/gmod/Game_Events) for a version of this hook called after the player entity has been created.⤶ ⤶ <note>This is only called clientside for listen server hosts.</note>⤶ <note>This is not called clientside for the local player.</note>⤶ </description>⤶ <realm>Shared</realm>⤶ <predicted>No</predicted>⤶ <args>⤶ <arg name="name" type="string">The player&#x27;s name.</arg>⤶ <arg name="ip" type="string">The player&#x27;s IP address. Will be &quot;none&quot; for bots.&#xA;&#xA;&lt;note&gt;This argument will only be passed serverside.&lt;/note&gt;</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>prints a message to the chatbox when a player joins the game</description>⤶ <code>⤶ function GM:PlayerConnect( name, ip )⤶ PrintMessage( HUD_PRINTTALK, name .. " has joined the game." )⤶ end⤶ </code>⤶ <output>Player1 has joined the game.</output>⤶ ⤶ </example>