View Single Post
10-30-17, 11:15 PM   #13
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
If you want to mute all sounds, use this:
Lua Code:
  1. local dummy = false
  2. hooksecurefunc('PlaySound', function(id)
  3.         if dummy then return end
  4.         dummy = true
  5.         local played, handle = PlaySound(id+1)
  6.         if played then
  7.             StopSound(handle-1)
  8.             StopSound(handle)
  9.         end
  10.         dummy = false
  11. end)

If you want to allow unique sounds, like the talking head monologues or any other uncommon sound, but not UI sounds, use this:
Lua Code:
  1. local dummy, kit = false, {}
  2. for _, v in pairs(SOUNDKIT) do kit[v] = true end
  3.  
  4. hooksecurefunc('PlaySound', function(id)
  5.         if dummy or (not kit[id]) then return end
  6.         dummy = true
  7.         local played, handle = PlaySound(id+1)
  8.         if played then
  9.             StopSound(handle-1)
  10.             StopSound(handle)
  11.         end
  12.         dummy = false
  13. end)

If you want to mute specific sounds use Kanegasi's solution. They all work the same way.
__________________

Last edited by MunkDev : 10-30-17 at 11:41 PM.
  Reply With Quote