• Welcome Sound?
    10 replies, posted
Hello everybody, im pretty new in Lua, and want to make a welcomesound, i've saw a tutorial but the tutorial doesn't work. First of all, here is the code: zRP_sound.lua: [CODE]function Joiningsound( ply ) resource.AddFile( "sound/welcome.mp3" ) ply:ConCommand( "play", "/welcome.mp3" ) end hook.Add( "PlayerInitialSpawn", "spawn", Joiningsound );[/CODE] And I've added to the init.lua: [CODE]AddCSLuaFile( "zRP_sound.lua" )[/CODE] It would be nice if someone helps me! best Regards kleinerOpa
dont use the /welcome, use welcome.mp3
[QUOTE=metrotyranno;41972940]dont use the /welcome, use welcome.mp3[/QUOTE] Don't work :/
Put this in your server autorun: [CODE] resource.AddFile( "sound/welcome.mp3" ) function WelcomeSound( ply ) ply:ConCommand("play", "welcome.mp3") ply:Chatprint("Welcome to the server!") end hook.Add( "PlayerInitialoSpawn", "PlaySound", WelcomeSound ) [/CODE]
[CODE]AddCSLuaFile() if ( CLIENT ) then function MyTotallyAwesomeSoundPlay() surface.PlaySound("folder/mysound.mp3") -- mp3 can be wav or ogg too end return end resource.AddFile( "sound/folder/mysound.mp3" ) hook.Add( "PlayerInitialSpawn", "MyAwesomeWelcomMsg", function ( ply ) ply:SendLua( "MyTotallyAwesomeSoundPlay()" ) end )[/CODE] Assuming all of this code is in one file and that file in is in autorun ( lua/autorun/whatever.lua ) Assuming your working sound file is located in "sound/folder/mysound.mp3".
[QUOTE=_FR_Starfox64;41974357]Put this in your server autorun: [CODE] resource.AddFile( "sound/welcome.mp3" ) function WelcomeSound( ply ) ply:ConCommand("play", "welcome.mp3") ply:Chatprint("Welcome to the server!") end hook.Add( "PlayerInitialoSpawn", "PlaySound", WelcomeSound ) [/CODE][/QUOTE] Where can i find them? I just test with Starting Local Server (ingame) Sould i install a Server with SteamCMD?
[QUOTE=kleinerOpa;41974543]Where can i find them? I just test with Starting Local Server (ingame) Sould i install a Server with SteamCMD?[/QUOTE] 1) He has a typo in the hook name ( It must be "PlayerInitialSpawn" ) 2) High chances are that the sound will play during the loading screen.
[QUOTE=Robotboy655;41974567]1) He has a typo in the hook name ( It must be "PlayerInitialSpawn" ) 2) High chances are that the sound will play during the loading screen.[/QUOTE] Suppose I would do that code in my Autorunfolder, than must other player do id do, right? But I want it automatically download if someone join.
You force them to download the sound using resource.AddFile You don't need to force script download because it is a serverside script (The one starfox posted). In my case however it is automatically sent to clients using AddCSLuaFile.
[QUOTE=Robotboy655;41974370][CODE]AddCSLuaFile() if ( CLIENT ) then function MyTotallyAwesomeSoundPlay() surface.PlaySound("folder/mysound.mp3") -- mp3 can be wav or ogg too end return end resource.AddFile( "sound/folder/mysound.mp3" ) hook.Add( "PlayerInitialSpawn", "MyAwesomeWelcomMsg", function ( ply ) ply:SendLua( "MyTotallyAwesomeSoundPlay()" ) end )[/CODE] Assuming all of this code is in one file and that file in is in autorun ( lua/autorun/whatever.lua ) Assuming your working sound file is located in "sound/folder/mysound.mp3".[/QUOTE] I had to add a timer.Simple to my script to get it working. Too much happening at initialSpawn for the script I am using. Dont know if it is needed with yours though.
[QUOTE=zapha;41976656]I had to add a timer.Simple to my script to get it working. Too much happening at initialSpawn for the script I am using. Dont know if it is needed with yours though.[/QUOTE] It is needed depending on the clients machine. I am not sure if there's a way to determine if client has fully joined.
Sorry, you need to Log In to post a reply to this thread.