@AlexDR15-legacy (AlexDR15) posted a new topic, subject "Join Server & Play Sound". It read:

   Hi guys!  
    I need something to my server.  
    I want a script that makes this:
    
      * When a player join the server, he hear a custom sound.  
    Only this.  
    Thanks so much!
    
    
    
    I know how to make this:
    
      * When player join the server, show to him a message.  
    This is that script:
    
    
    [code] 
        -- Code to show a message to a player, when he joins the server
        function Spawn ( ply )
        	ply:PrintMessage (HUD_PRINTTALK, "Welcome " .. ply:Nick () .. ", enjoy with us!")
        end
        hook.Add( "PlayerSpawn", "spawnmessage", Spawn )
        
        
    [/code]

So @code_gs-legacy (code_gs) replied

    You'll have to network it clientside and use this function: http://wiki.garrysmod.com/page/surface/PlaySound

To which @StonedPenguin-legacy (StonedPenguin) replied

    code_gs:
    
    > You'll have to network it clientside and use this function: http://wiki.garrysmod.com/page/surface/PlaySound
    
    No need to network it,
    
    wiki.facepunch.com
    
    ### Garry's Mod Wiki
    
    Welcome to the Garry's Mod Wiki! Current game discussion as well as update progress can be found on Discord. You can test changes for the next update on the Dev beta branch through Steam. The Garry's Mod Lua Source Code is available on GitHub. To...
    
    GM/InitPostEntity clientside should do.

After which, @code_gs-legacy (code_gs) added

    StonedPenguin:
    
    > No need to network it,
    > 
    > http://wiki.garrysmod.com/favicon.ico
    > 
    > GM/InitPostEntity clientside should do.
    
    Too early; player will still be on the loading screen and will not hear it

@StonedPenguin-legacy (StonedPenguin) replied

    code_gs:
    
    > Too early; player will still be on the loading screen and will not hear it
    
    http://wiki.garrysmod.com/page/Category:timer

Then @code_gs-legacy (code_gs) said

    StonedPenguin:
    
    > http://wiki.garrysmod.com/page/Category:timer
    
    Or just put it in PlayerInitalSpawn and avoid the hacky guess times.

To which @StonedPenguin-legacy (StonedPenguin) replied

    code_gs:
    
    > Or just put it in PlayerInitalSpawn and avoid the hacky guess times.
    
    PlayerInitalSpawn is called before the player entity is created and would cause the same issue

After which, @code_gs-legacy (code_gs) added

    StonedPenguin:
    
    > PlayerInitalSpawn is called before the player entity is created and would cause the same issue
    
    Not if the player hasn't selected a team/spawned; depends totally on the gamemode.

So @AlexDR15-legacy (AlexDR15) replied

    The gamemode it's for Trouble in Terrorist Town. When the people see the Motd (for example). I'm not a coder, can you make a script? Thanks for reply!


{'source': 'discourse', 'url': 'https://forum.facepunch.com/t/join-server-play-sound/202467', 'title': 'Join Server & Play Sound', 'views': 492, 'has_accepted_answer': False, 'word_count': 361, 'like_count': 0, 'reply_count': 8, 'participant_count': 3, 'posts': 9, 'tags': '', 'author': '@AlexDR15-legacy (AlexDR15)', 'participants': '@AlexDR15-legacy (AlexDR15), @code_gs-legacy (code_gs), @StonedPenguin-legacy (StonedPenguin)', 'image_url': [None], 'created_at': '2015-04-28T02:23:17.000Z', 'last_posted_at': '2015-04-28T12:54:14.000Z'}