Garry's Mod Wiki

Revision Difference

Entity:EmitSound#547070

<function name="EmitSound" parent="Entity" type="classfunc"> <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. <note>When using this function with weapons, use the <page>Weapon</page> itself as the entity, not its owner!</note> <bug issue="2651">This does not respond to <page>Global.SuppressHostEvents</page>.</bug> </description> <realm>Shared</realm> <args> <arg name="soundName" type="string">The name of the sound to be played. <warning>The string cannot have whitespace at the start or end. You can remove this with <page>string.Trim</page>.</warning></arg>⤶ ⤶ This should either be a sound script name (<page>sound.Add</page>) or a file path relative to the `sound/` folder. (Make note that it's not sound**s**)⤶ ⤶ <warning>The string cannot have whitespace at the start or end. You can remove this with <page>string.Trim</page>.</warning></arg>⤶ <arg name="soundLevel" type="number" default="75">A modifier for the distance this sound will reach, acceptable range is 0 to 511. 100 means no adjustment to the level. See <page>Enums/SNDLVL</page> Will not work if a [sound script](https://developer.valvesoftware.com/wiki/Soundscripts) is used.</arg> <arg name="pitchPercent" type="number" default="100">The pitch applied to the sound. The acceptable range is from 0 to 255. 100 means the pitch is not changed.</arg> <arg name="volume" type="number" default="1">The volume, from 0 to 1.</arg> <arg name="channel" type="number" default="CHAN_AUTO, CHAN_WEAPON for weapons">The sound channel, see <page>Enums/CHAN</page>. Will not work if a [sound script](https://developer.valvesoftware.com/wiki/Soundscripts) is used.</arg> <arg name="soundFlags" type="number" default="0">The flags of the sound, see <page>Enums/SND</page></arg> <arg name="dsp" type="number" default="0">The DSP preset for this sound. [List of DSP presets](https://developer.valvesoftware.com/wiki/Dsp_presets)</arg> </args> </function> <example> <description>Plays sound from the first player on the server.</description> <code> 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" ) </code> </example>