Ulysses
General => Developers Corner => Topic started by: joe c-j on August 16, 2008, 11:03:25 AM
-
Hi I'm a noob Lua scripter so was wondering if anyone would help me. What i would like on my server is to have it play a music file whenever someone new joins. If someone could post a lua script and location to put it so my server would do that i would be most grateful. And if there is another way to do that could you post that as well. Thanks in anticipation.
-
Not tested, but should work. Save as something.lua, and place it in your <server>/garrysmod/lua/autorun directory.
OnJoinSound = "music/hl2_song20_submix0.mp3" // Sound file relative to the sound directory
function PlaySoundOnJoin(ply)
for k,v in pairs(player.GetAll()) do
v:SendLua("surface.PlaySound(\"OnJoinSound\"");
end
end
hook.Add("PlayerInitialSpawn", "PlaySoundOnJoinHook", PlaySoundOnJoin)
Enjoy!
-
"whenever someone new joins". What do you mean by that?
-
Yeah I thought about that too when writing this scripts.
By "new" do you mean:
-First time a specifc player has joined the server ever?
-Or just whenever a player joins the server regardless if they've been there before?
-
Also, did he mean it to play to all players, or just the one joining?
If I'm joining a server and have to hear music playing, annoying, but, once when joining ok.
Everytime any other player joins? Yuck.
-
sorry for not being specific enough and thanks for your help so far...to answer your questions i was hoping that it would play just to the user joining the server and only the first time they join the server
where i can insert my own mp3 file my changing the name and file location could you highlight that on the script please
thank you
-
The clients connecting to you would have to already have the MP3 in their sound directory, so, if you change it to some custom MP3, and aren't 100% sure they'll download the file, they won't hear the music anyway.
As for the first-time-only deal...maybe handle that by UniqueID?