Entity/EmitSound

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Added example because of new feature that confuses newcomers ( default value in function output ))
(Make the example work by copy-pasting.)
Line 3: Line 3:
 
|Parent=Entity
 
|Parent=Entity
 
|Description=Plays a sound on an entity. If run clientside, the sound will only be heard locally.
 
|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 )
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=Yes
 
|IsClass=Yes
Line 37: Line 39:
 
}}
 
}}
 
{{Example
 
{{Example
|Description=Plays sound from an entity; if Player or NPC character with the mouth rigged, the character will "lip-sync".
+
|Description=Plays sound from the first player on the server.
|Code=Entity:EmitSound( "path/to/sound/wav", 75, 100, 1, CHAN_AUTO );
+
|Code=Entity(1):EmitSound( "path/to/sound/wav", 75, 100, 1, CHAN_AUTO ) -- Same as below
|Output=Will play audio stemming from the object reference stored in "Entity" variable.
+
Entity(1):EmitSound( "path/to/sound/wav" ) -- You can remove the arguments that have default values.
 
}}
 
}}

Revision as of 23:24, 23 October 2014

 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 )

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 this is instead set to 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