Squirrel/Server/Functions/Sounds/FindSound

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with '{{Squirrel/Title|FindSound}} This function finds a ''Sound'' from an ID/name and returns the pointer. If no sound is found, ''null'' will be returned. == Syntax == <code>sound …')
 
 
Line 14: Line 14:
 
== Example ==
 
== Example ==
  
{{Squirrel/NeedsExample}}
+
This will try and find 'moo.mp3' when the player types '/findsound'.
Explanation for the example
+
  
 
<code lang="squirrel">
 
<code lang="squirrel">
-- Todo
+
function onPlayerCommand( pPlayer, szCommand, szText )
 +
{
 +
if ( szCommand == "findsound" )
 +
{
 +
local pSound = FindSound( "moo.mp3" );
 +
if ( pSound ) MessagePlayer( "moo.mp3 was found!", pPlayer );
 +
}
 +
 +
return 1;
 +
}
 +
 
 
</code>
 
</code>
  
 
=== Notes ===
 
=== Notes ===
  
-- List of used functions and other notes here.
+
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Functions/Sounds}}
 
{{Squirrel/Server/Functions/Sounds}}

Latest revision as of 17:07, 25 October 2010

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

This function finds a Sound from an ID/name and returns the pointer. If no sound is found, null will be returned.

[edit] Syntax

  1. sound FindSound( string name )
  1. sound FindSound( int id )

[edit] Arguments

  • name - The name of the sound (including extension) e.g. boo.mp3
  • id - The ID of the sound to be found

[edit] Example

This will try and find 'moo.mp3' when the player types '/findsound'.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "findsound" )
  5. {
  6. local pSound = FindSound( "moo.mp3" );
  7. if ( pSound ) MessagePlayer( "moo.mp3 was found!", pPlayer );
  8. }
  9. return 1;
  10. }
  11.  
  12.  

[edit] Notes

The function MessagePlayer and event onPlayerCommand were used in this example. More info about them in the corresponding pages.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox