Entity.StopSound

From GMod Wiki

Revision as of 00:28, 20 November 2010 by Jespercal (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax Entity:StopSound( String filename )
Description:
A sound being emitted from the entity with the given filename is halted.
Returns: nil
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.StopSound]Entity.StopSound [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionN/A
Used onNewerMissing.png
Code
LuaIco3.pngThis page needs an example to demonstrate the item detailed on this page. See how to make one here.
See more articles that need examples here.
OutputN/A

The code snippet below (taken from the TurnOn function of a Life Support 3 entity) demonstrates how ENT:StopSound could be used:

 
function ENT:TurnOn()
    if ( self.Active == 0 ) then
        self:StopSound( "soundfile1.wav" )
        self:EmitSound( "soundfile2.wav" )
	self:EmitSound( "soundfile3.wav" )
        self.Active = 1
    end
end
 


self:StopSound( "soundfile1.wav" ) <-- Stopping the first sound file

self:EmitSound( "soundfile2.wav" ) <-- Starting the second sound file

self:EmitSound( "soundfile3.wav" ) <-- Starting the thrid sound file


From the code above, you can see that turning on the entity would stop soundfile1 from playing and start soundfile2 and soundfile3. It would also set the entity state to active (Active=1), if it is not already active.

Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox