Squirrel/Server/Functions/Sounds/Play

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
m
m
 
Line 22: Line 22:
 
if ( sound )
 
if ( sound )
 
{
 
{
sound.Open();
+
sound.Open( pPlayer );
 
sound.Play( pPlayer );
 
sound.Play( pPlayer );
 +
sound.Close( pPlayer );
 
}
 
}
 
}
 
}

Latest revision as of 14:28, 17 August 2011

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This function plays a local sound stored in the server files.

[edit] Syntax

  1. bool Sound.Play( player plr )

[edit] Arguments

  • plr - The player to play the sound for

[edit] Example

This code will play the sound 'moo.mp3' for a player when they type '/moo'.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "moo" )
  5. {
  6. local sound = FindSound( "moo.mp3" );
  7. if ( sound )
  8. {
  9. sound.Open( pPlayer );
  10. sound.Play( pPlayer );
  11. sound.Close( pPlayer );
  12. }
  13. }
  14. return 1;
  15. }
  16.  

[edit] Notes

The event onPlayerCommand was used in this example. More info about this in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox