Garry's Mod Wiki

Garry's Mod Wiki

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

Description

Emits the specified sound at the specified position. See also Entity:EmitSound if you wish to play sounds on a specific entity.

Valid sample rates: 11025 Hz, 22050 Hz and 44100 Hz, otherwise you may see this kind of message:

Unsupported 32-bit wave file your_sound.wav and Invalid sample rate (48000) for sound 'your_sound.wav'

Arguments

1 string soundName
The sound to play

This should either be a sound script name (sound.Add) or a file path relative to the sound/ folder. (Make note that it's not sounds)

2 Vector position
The position where the sound is meant to play, which is also used for a network filter (CPASAttenuationFilter) to decide which players will hear the sound.
3 number entity = 0
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 CHAN enum.
5 number volume = 1
The volume of the sound, from 0 to 1
6 number soundLevel = 75
The sound level of the sound, see SNDLVL enum
7 number soundFlags = 0
The flags of the sound, see SND enum
8 number pitch = 100
The pitch of the sound, 0-255
9 number dsp = 0
The DSP preset for this sound. List of DSP presets
10 CRecipientFilter filter = nil
If set serverside, the sound will only be networked to the clients in the filter.

Example

Plays magical sound on first player.

-- Plays the sound attached to the given entity (by its entity index) EmitSound( "garrysmod/save_load1.wav", Entity(1):GetPos(), 1, CHAN_AUTO, 1, 75, 0, 100 ) -- Plays the sound in any custom position EmitSound( "Weapon_AR2.Single", Entity(1):GetPos() )

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...