Entity.StopSound
From GMod Wiki
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: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Entity.StopSound]Entity.StopSound [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | N/A | ||
---|---|---|---|
Used on | |||
Code |
| ||
Output | N/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
- This doesn't seem to work. For looping sounds, use CreateSound() instead.