Squirrel/Server/Functions/Sounds/FindSound
From Liberty Unleashed Wiki
(Difference between revisions)
(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 == | ||
− | + | This will try and find 'moo.mp3' when the player types '/findsound'. | |
− | + | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | + | 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 === | ||
− | + | 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
This function finds a Sound from an ID/name and returns the pointer. If no sound is found, null will be returned.
[edit] Syntax
sound FindSound( string name )
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'.
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "findsound" ) { local pSound = FindSound( "moo.mp3" ); if ( pSound ) MessagePlayer( "moo.mp3 was found!", pPlayer ); } return 1; }
[edit] Notes
The function MessagePlayer and event onPlayerCommand were used in this example. More info about them in the corresponding pages.