Garry's Mod Wiki

Entity:EmitSound

Entity:EmitSound( string soundName, number soundLevel = 75, number pitchPercent = 100, number volume = 1, number channel = CHAN_AUTO, CHAN_WEAPON for weapons )

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". This does not work with all sound files.

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.

When using this function with weapons, use the Weapon itself as the entity, not its owner!
Do not use this for looping sounds with a filepath: see Entity:StopSound for more details.
This does not respond to SuppressHostEvents.

Arguments

1 string soundName
The name of the sound to be played.

The string will cannot have whitespace at the start or end. You can remove this with string.Trim.
2 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 Enums/SNDLVL

Will not work if a sound script is used.

3 number pitchPercent = 100
The pitch applied to the sound. The acceptable range is from 0 to 255. 100 means the pitch is not changed.
4 number volume = 1
The volume, from 0 to 1.
5 number channel = CHAN_AUTO, CHAN_WEAPON for weapons
The sound channel, see Enums/CHAN.

Will not work if a sound script is used.

Example

Plays sound from the first player on the server.

Entity(1):EmitSound( "garrysmod/save_load1.wav", 75, 100, 1, CHAN_AUTO ) -- Same as below Entity(1):EmitSound( "garrysmod/save_load1.wav" ) -- You can remove the arguments that have default values. Entity(1):EmitSound( "Weapon_AR2.Single" )

Page Links


Special Pages


Wikis

?

Render Time: 52ms

DB GetPage 4
Generate Html 17
SaveChanges (1) 23
Render Body 0
Render Sidebar 5