sound/Add

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=Add |Parent=sound |Description=Creates a sound. |Realm=Shared |IsClass=No }} {{Arg |type=SoundData |name=sound_data |desc=The sounds properties. }} {{Ex...")
 
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=Add
+
|Description=Creates a sound script. It can also override sounds, which seems to only work when set on the server.
|Parent=sound
+
|Description=Creates a sound.
+
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=No
 
|IsClass=No
 
}}
 
}}
 
{{Arg
 
{{Arg
|type=SoundData
+
|type=table
|name=sound_data
+
|name=soundData
|desc=The sounds properties.
+
|desc=The sounds properties. See {{Struct|SoundData}}
 
}}
 
}}
 
{{Example
 
{{Example
| Description = "Creates a sound."
+
|Description=Creates a sound script. It will automatically vary in pitch and be played in a given audio channel to better control which sounds mix with which sounds and how.
| Code =  
+
 
sound.Add(
+
In this example, the file location could be: ( Choose one )
{
+
* garrysmod/sound/vehicles/enzo/idle.wav
name = "enzo_engine_idle",
+
* garrysmod/gamemodes/MyCoolGameMode/content/sound/vehicles/enzo/idle.wav
channel = CHAN_STATIC,
+
* garrysmod/addons/myCoolAddon/sound/vehicles/enzo/idle.wav
volume = 1.0,
+
* garrysmod/addons/myCoolAddon/gamemodes/MyCoolGameMode/content/sound/vehicles/enzo/idle.wav
soundlevel = 80,
+
|Code=sound.Add( {
pitchstart = 95,
+
name = "enzo_engine_idle",
pitchend = 110,
+
channel = CHAN_STATIC,
sound = "vehicles/enzo/idle.wav"
+
volume = 1.0,
})
+
level = 80,
 +
pitch = {95, 110},
 +
sound = "vehicles/enzo/idle.wav"
 +
} )
 +
|Output=You can now play your custom '''sound script''' with {{ClassFunction|Entity|EmitSound}} like so:
 +
<code>Entity( 1 ):EmitSound( "enzo_engine_idle" )</code>
 
}}
 
}}

Latest revision as of 03:48, 18 December 2016

 sound.Add( )

Contents

Description

Creates a sound script. It can also override sounds, which seems to only work when set on the server.

Arguments

table soundData

The sounds properties. See SoundData structure

Examples

Example

Creates a sound script. It will automatically vary in pitch and be played in a given audio channel to better control which sounds mix with which sounds and how.

In this example, the file location could be: ( Choose one )

  • garrysmod/sound/vehicles/enzo/idle.wav
  • garrysmod/gamemodes/MyCoolGameMode/content/sound/vehicles/enzo/idle.wav
  • garrysmod/addons/myCoolAddon/sound/vehicles/enzo/idle.wav
  • garrysmod/addons/myCoolAddon/gamemodes/MyCoolGameMode/content/sound/vehicles/enzo/idle.wav
sound.Add( {
	name = "enzo_engine_idle",
	channel = CHAN_STATIC,
	volume = 1.0,
	level = 80,
	pitch = {95, 110},
	sound = "vehicles/enzo/idle.wav"
} )

Output:

You can now play your custom sound script with Entity:EmitSound like so: Entity( 1 ):EmitSound( "enzo_engine_idle" )
Personal tools
Navigation