Entity/EmitSound

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(note template - arguable, since it's within a function argument and not the description)
Line 4: Line 4:
 
If used on a player or NPC character with the mouth rigged, the character will "lip-sync". ( Does not work with all sounds )
 
If used on a player or NPC character with the mouth rigged, the character will "lip-sync". ( Does not work with all sounds )
  
You can only override the volume and pitch if you use the filename, not the sound script/manifest name.
+
{{Note|You can only override the volume and pitch if you use the filename, not the sound script/manifest name.}}
  
It is recommended to use sound scripts ( see {{LibraryFunction|sound|Add}} ) over direct file paths. There are many inconsistencies, especially when the sound is played on a {{Type|Weapon}}
+
{{Note|It is recommended to use sound scripts ( see {{LibraryFunction|sound|Add}} ) over direct file paths. This will allow you to use {{ClassFunction|Entity|StopSound}} to stop the played sound scripts.}}
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=Yes
 
|IsClass=Yes
|Name=EmitSound
 
|Parent=Entity
 
 
}}
 
}}
 
{{Arg
 
{{Arg

Revision as of 14:18, 12 July 2017

 Entity:EmitSound( )

Contents

Description

Plays a sound on an entity. If run clientside, the sound will only be heard locally.

If used on a player or NPC character with the mouth rigged, the character will "lip-sync". ( Does not work with all sounds )

NOTE

You can only override the volume and pitch if you use the filename, not the sound script/manifest name.

NOTE

It is recommended to use sound scripts ( see sound.Add ) over direct file paths. This will allow you to use Entity:StopSound to stop the played sound scripts.

Arguments

string soundName

The name of the sound to be played.

Arguments

number soundLevel=75

A modifier for the distance this sound will reach, acceptable range is 0 to 511. 100 means no adjustment to the level. See SNDLVL_ Enums

Arguments

number pitchPercent=100

The pitch applied to the sound. The acceptable range is from 0 to 255. 100 means the pitch is not changed.

Arguments

number volume=1

The volume, from 0 to 1.

Arguments

number channel=CHAN_AUTO

The sound channel , see CHAN_ Enums

NOTE

For weapons, the default is CHAN_WEAPON.

Examples

Example

Plays sound from the first player on the server.

Entity(1):EmitSound( "path/to/sound/wav", 75, 100, 1, CHAN_AUTO ) -- Same as below
Entity(1):EmitSound( "path/to/sound/wav" ) -- You can remove the arguments that have default values.


Personal tools
Navigation