Liberty Unleashed
Scripting => Scripting Discussion => Topic started by: Trot 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();
}
}
-
You never close it
-
You never close it
You mean "return"?
-
Here I updated the code, added the returns and also neatened it up, but I have not tested it.
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();
return 1;
}
}
else
{
spawn_Sound.Play();
return 1;
}
}
Regards Orpheus