Entity/EmitSound
m (Bug) |
Robotboy655 (Talk | contribs) |
||
Line 4: | Line 4: | ||
If used on a player or NPC character with the mouth rigged, the character will "lip-sync". ( Does not work with all sounds ) | If used on a player or NPC character with the mouth rigged, the character will "lip-sync". ( Does not work with all sounds ) | ||
− | {{Note|You can only override the volume and pitch if you use | + | {{Note|You can only override the volume and pitch if you use a direct filename, not a |
+ | [https://developer.valvesoftware.com/wiki/Soundscripts sound script] name.}} | ||
{{Note|It is recommended to use sound scripts ( see {{LibraryFunction|sound|Add}} ) over direct file paths. This will allow you to use {{ClassFunction|Entity|StopSound}} to stop the played sound scripts.}} | {{Note|It is recommended to use sound scripts ( see {{LibraryFunction|sound|Add}} ) over direct file paths. This will allow you to use {{ClassFunction|Entity|StopSound}} to stop the played sound scripts.}} | ||
+ | |||
+ | {{Note|When using this function with weapons, use the {{Type|Weapon}} itself as the entity, not its owner!}} | ||
{{Bug|Issue=2651|This does not respond to {{GlobalFunction|SuppressHostEvents}}.}} | {{Bug|Issue=2651|This does not respond to {{GlobalFunction|SuppressHostEvents}}.}} |
Revision as of 05:24, 21 September 2018
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 )
NOTE |
You can only override the volume and pitch if you use a direct filename, not a sound script name. |
NOTE |
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. |
NOTE |
When using this function with weapons, use the Weapon itself as the entity, not its owner! |
BUG |
This does not respond to SuppressHostEvents. Issue Tracker: #2651 |
Arguments
string soundName
The name of the sound to be played.
NOTE |
Ensure this string has no whitespace at the start or end (you can use string.Trim), or else you'll get an error. |
Arguments
number soundLevel=75
Arguments
number pitchPercent=100
Arguments
number volume=1
Arguments
number channel=CHAN_AUTO
The sound channel , see CHAN_ Enums
NOTE |
For weapons, the default is 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.