Garry's Mod Wiki

EmitSound

void EmitSound( string soundName, Vector position, number entity, number channel = CHAN_AUTO, number volume = 1, number soundLevel = 75, number soundFlags = 0, number pitch = 100 )

Description

Emits the specified sound at the specified position.

Sounds must be precached serverside manually before they can be played. util.PrecacheSound does not work for this purpose, Entity.EmitSound does the trick
This does not work with soundscripts. TODO: Is this a bug or intended?

Arguments

1 string soundName
The sound to play
2 Vector position
The position to play at
3 number entity
The entity to emit the sound from. Can be an Entity:EntIndex or one of the following:

  • 0 - Plays sound on the world (Position set to 0,0,0)
  • -1 - Plays sound on the local player (on server acts as 0)
  • -2 - Plays UI sound (Position set to 0,0,0, no spatial sound,on server acts as 0)
4 number channel = CHAN_AUTO
The sound channel, see Enums/CHAN.
5 number volume = 1
The volume of the sound, from 0 to 1
6 number soundLevel = 75
The sound level of the sound, see Enums/SNDLVL
7 number soundFlags = 0
The flags of the sound, see Enums/SND
8 number pitch = 100
The pitch of the sound, 0-255

Example

Plays magical sound on first player.

EmitSound( Sound("garrysmod/save_load1.wav"), Entity(1):GetPos(), 1, CHAN_AUTO, 1, 75, 0, 100 )

Page Links


Special Pages


Wikis

?

Render Time: 36ms

Session 0
DB GetPage 4
Generate Html 8
SaveChanges 9
Render Body 0
Render Sidebar 12