ULX

Author Topic: Music Intro to server help  (Read 5216 times)

0 Members and 1 Guest are viewing this topic.

Offline joe c-j

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Music Intro to server help
« 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.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Music Intro to server help
« Reply #1 on: August 16, 2008, 02:03:36 PM »
Not tested, but should work. Save as something.lua, and place it in your <server>/garrysmod/lua/autorun directory.

Code: [Select]
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!
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Music Intro to server help
« Reply #2 on: August 16, 2008, 03:48:20 PM »
"whenever someone new joins". What do you mean by that?
Experiencing God's grace one day at a time.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Music Intro to server help
« Reply #3 on: August 16, 2008, 09:17:02 PM »
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?
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Music Intro to server help
« Reply #4 on: August 16, 2008, 09:49:20 PM »
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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline joe c-j

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Music Intro to server help
« Reply #5 on: August 17, 2008, 05:46:55 PM »
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

Offline sparky2002b

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
  • CloudNine Clan Administrator
Re: Music Intro to server help
« Reply #6 on: August 21, 2008, 01:38:59 PM »
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?
CloudNine Clan Server - 68.64.33.152:27019 - http://c9gc.com