Garry's Mod Wiki

GM:EntityEmitSound

boolean GM:EntityEmitSound( table data )

Description

Called whenever a sound has been played. This will not be called clientside if the server played the sound without the client also calling Entity:EmitSound.

This is not called for scripted sequences.

Issue Tracker: 1021

Arguments

1 table data
Information about the played sound. Changes done to this table can be applied by returning true from this hook.

See Structures/EmitSoundInfo.

Returns

1 boolean
  • Return true to apply all changes done to the data table.
  • Return false to prevent the sound from playing.
  • Return nil or nothing to play the sound without altering it.

Example

Slows down all sounds to reflect game.SetTimeScale.

local cheats = GetConVar( "sv_cheats" ) local timeScale = GetConVar( "host_timescale" ) hook.Add( "EntityEmitSound", "TimeWarpSounds", function( t ) local p = t.Pitch if ( game.GetTimeScale() ~= 1 ) then p = p * game.GetTimeScale() end if ( timeScale:GetInt() ~= 1 and cheats >= 1 ) then p = p * timeScale:GetInt() end if ( p ~= t.Pitch ) then t.Pitch = math.Clamp( p, 0, 255 ) return true end if ( CLIENT and engine.GetDemoPlaybackTimeScale() ~= 1 ) then t.Pitch = math.Clamp( t.Pitch * engine.GetDemoPlaybackTimeScale(), 0, 255 ) return true end end )

Page Links


Special Pages


Wikis

?

Render Time: 37ms

DB GetPage 4
Generate Html 8
SaveChanges (1) 9
Render Body 0
Render Sidebar 12