• Disabling certain sounds from being played through SoundEmitter in Wiremod
    5 replies, posted
Hello! I want to disable some sounds from being played in Sound Emitter in Wiremod, Sound Emitter is quite a good tool for alarms and generally cool structures, though it can be annoying having people put LOUD sounds that everyone can hear, and annoy alot of people. Is there possibly a way I could turn some Sound Emitter sounds Off? (Unuseable) Thank you.
Try putting this lua script in garrysmod/lua/autorun/wire_soundemitter_blacklist.lua on the server. local blacklistedSounds = { ["vo/npc/barney/ba_damnit.wav"] = true, } hook.Add("CanTool", "wire_soundemitter_blacklist", function(ply, _, tool) if tool ~= "wire_soundemitter" then return end if blacklistedSounds[ply:GetInfo("wire_soundemitter_sound")] then ply:ChatPrint("That wire sound emitter sound is blacklisted!") return false end end) You can add whatever sounds you like in the blacklistedSounds table. Also, bear in mind, this won't block duplicator / any other method of creating sound emitters outside of the toolgun.
Thank you! Just one question, considering people would be able to dupe sound emitters, why does the following not work? if tool ~= "wire_soundemitter" or tool ~= "advdupe2" then return end 
Because duplicated Sound Emitters store their sound settings in the entity being spawned, and not in the convar. Also, that conditional will always return true, when dealing with negatives you need an and, not an or. x == 1 or x == 2 x ~= 1 and x ~= 2
Thank you so much! You're a lifesaver.
For some reason, GmodLua decides adding prints should make it work, and removing them blocks the complete use of AdvDupe 2. This worked, with prints: hook.Add("CanTool", "wire_soundemitter_blacklist", function(ply, tr, tool) print("1") if tool ~= "wire_soundemitter" and tool ~= "advdupe2" then print ("2") return end if blacklistedSounds[ply:GetInfo("wire_soundemitter_sound")] then ply:ChatPrint("That wire sound emitter sound is blacklisted!") return false end end) This did not, without prints: hook.Add("CanTool", "wire_soundemitter_blacklist", function(ply, tr, tool) if tool ~= "wire_soundemitter" and tool ~= "advdupe2" then return end if blacklistedSounds[ply:GetInfo("wire_soundemitter_sound")] then ply:ChatPrint("That wire sound emitter sound is blacklisted!") return false end end)
Sorry, you need to Log In to post a reply to this thread.