Author Topic: Music on Spawn (Script)  (Read 3235 times)

Trot

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-1
    • View Profile
Music on Spawn (Script)
« on: April 12, 2011, 08:42:43 pm »
Shnurok and I, as an assistant, developed a script that plays music when player spawn.

Here it is:

function onScriptLoad()
{
spawn_Sound <- null;
}

function onClientSpawn( player )
{
if ( !spawn_Sound )
{
spawn_Sound = FindSound( "mysound.mp3" );
if ( spawn_Sound )
{
spawn_Sound.Open();
spawn_Sound.Play();
}
}
else
{
spawn_Sound.Play();
}
}

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Music on Spawn (Script)
« Reply #1 on: April 12, 2011, 11:46:41 pm »
You never close it

Trot

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-1
    • View Profile
Re: Music on Spawn (Script)
« Reply #2 on: April 13, 2011, 12:10:33 am »
You never close it

You mean "return"?

Orpheus

  • Newbie
  • *
  • Posts: 49
  • Karma: +1/-0
  • Music is a way of life.
    • View Profile
    • Orphtown UK
Re: Music on Spawn (Script)
« Reply #3 on: April 14, 2011, 09:24:18 pm »
Here I updated the code, added the returns and also neatened it up, but I have not tested it.

Code: [Select]
function onScriptLoad()
{
     spawn_Sound <- null;
}

Code: [Select]
function onClientSpawn( player )
{
    if ( !spawn_Sound )
    {
         spawn_Sound = FindSound( "mysound.mp3" );
         if ( spawn_Sound )
         {
              spawn_Sound.Open();
              spawn_Sound.Play();
              return 1;
         }
    }
    else
    {
         spawn_Sound.Play();
         return 1;
    }
}

Regards Orpheus
« Last Edit: April 14, 2011, 09:26:11 pm by Orpheus »

Windows: A 64-bit/32-bit extension to a 16-bit GUI on an 8-bit OS written for a 4-bit architecture by a 2-bit company who can not stand 1-bit of competition.

 

© Liberty Unleashed Team.