Key voice

Hi, facepunch.
How to switch-off the button of a voice chat?

Happy birthday, godred2 :smile:

Not tested so no clue if this will actually work but try this:

[lua]if SERVER then
hook.Add( “PlayerCanHearPlayersVoice”, “disableVoice”, function() return true end )
end[/lua]

I already used this script.
I should remove the button of the Voice Chat
But I don’t know as.
Here the button of a voice isn’t present - http://wiki.garrysmod.com/page/Enums/IN

I didn’t quite understand your post, so I assumed by button you meant the vgui thing. It shouldn’t appear if the player can’t speak, but just in case:

[lua]
local function CreateVoiceVGUI()

g_VoicePanelList = vgui.Create( "DPanel" )

g_VoicePanelList:ParentToHUD()
g_VoicePanelList:SetPos( ScrW() - 300, 100 )
g_VoicePanelList:SetSize( 250, ScrH() - 200 )
g_VoicePanelList:SetDrawBackground( false )

end

hook.Add( “InitPostEntity”, “CreateVoiceVGUI”, CreateVoiceVGUI )
[/lua]

This is the code that houses the voice chat boxes. In the code, if it doesn’t exist, nothing is drawn (in other words, Garry thought far enough ahead to deal with this question).

if your code is run BEFORE InitPostEntity, run this:
[lua]
hook.Remove( “InitPostEntity”, “CreateVoiceVGUI” )
[/lua]

if it is run AFTER InitPostEntity, run this:
[lua]
g_VoicePanelList = nil
[/lua]

If you are unsure, just run them both (won’t do any harm). This code should be ran clientside.

How to switch off a microphone at the chosen player?

You could either use the hook posted above, or use

Player:SetMuted( true )

Script doesn’t work.
The player can speak.
Errors in console are absent(Not Errors)



function PlayerMuteG( ply )
 if ply:GetNWBool( "gag") then
         ply:SetMuted( true )
 end
end