Garry's Mod Wiki

Revision Difference

sound.Add#528437

<function name="Add" parent="sound" type="libraryfunc"> <description>Creates a sound script. It can also override sounds, which seems to only work when set on the server.</description> <realm>Shared</realm> <args> <arg name="soundData" type="table">The sounds properties. See <page>Structures/SoundData</page></arg> </args> </function> <example> <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. 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⤶ In this example, the file location could be: (Choose one) * garrysmod/sound/`phx/explode03.wav`⤶ * garrysmod/gamemodes/MyCoolGameMode/content/sound/`phx/explode03.wav`⤶ * garrysmod/addons/myCoolAddon/sound/`phx/explode03.wav`⤶ * garrysmod/addons/myCoolAddon/gamemodes/MyCoolGameMode/content/sound/`phx/explode03.wav`⤶ </description> <code> sound.Add( { name = "enzo_engine_idle", name = "big_explosion", channel = CHAN_STATIC, volume = 1.0, level = 80, pitch = {95, 110}, sound = "vehicles/enzo/idle.wav" sound = "phx/explode03.wav" } ) </code> <output> You can now play your custom **sound script** with <page>Entity:EmitSound</page> like so: ``` Entity( 1 ):EmitSound( "enzo_engine_idle" ) Entity( 1 ):EmitSound( "big_explosion" ) ``` </output> </example>