Is there a better way to mute a player ( for the entire server ) than just making him do "-voicerecord" ? Because you can just spam your bind and it will let you speak.
Clientside Player.SetMuted
Ripped from Evolve's 'sh_mute.lua'
[lua]
function PLUGIN:PlayerStartVoice( ply )
if ( LocalPlayer():GetNWBool( "Muted" ) ) then
RunConsoleCommand( "-voicerecord" )
end
end
[/lua]
[QUOTE=Chessnut;35114131]Clientside:
Player:SetMuted(bool Muted)
Edit:
Ninja'd.[/QUOTE]
HA, I said it before you Chess.
:v:
I said I didn't want it to just do -voicerecord.....
Anyways, I guess I can do the SetMuted( bool ).. I was looking into that but didn't really want to do that... I wanted it so they knew they couldn't talk.. But I guess I could do both since -voicerecord gives the visual and SetMuted actually does the correct muting.
Just for the record, would it be possible for someone to make a module that like stops the +voicerecord going through? Or would that not work?
[lua]
local _runCC = RunConsoleCommand;
local _plyCC = _R.Player.ConCommand
function RunConsoleCommand( cmd )
if( cmd == "-voicerecord" ) then
return false;
end
return _runCC( cmd );
end
function _R.Player:ConCommand( cmd )
if( cmd == "-voicerecord" ) then
return false;
end
return _plyCC( cmd );
end
[/lua]
Untested, should work in theory.
Oh, so you can actually overwrite commands? I did not know. Thanks, I'll try that.
[QUOTE=JustSoFaded;35130368][lua]
local _runCC = RunConsoleCommand;
local _plyCC = _R.Player.ConCommand
function RunConsoleCommand( cmd )
if( cmd == "-voicerecord" ) then
return false;
end
return _runCC( cmd );
end
function _R.Player:ConCommand( cmd )
if( cmd == "-voicerecord" ) then
return false;
end
return _plyCC( cmd );
end
[/lua]
Untested, should work in theory.[/QUOTE]
You might be looking for the PlayerBindPress hook.
[lua]
hook.Add("PlayerBindPress", "noSpeaking", function(bind)
-- Do your if statements here.
if ( string.find(bind, "+voicerecord") ) then
return false;
end;
end);
[/lua]
No, that just stops people from talking. He wants to make it so people using hacks such as SethHack can't force +voicerecord so they can still talk while muted.
[editline]14th March 2012[/editline]
Also, in my code I accidentally typed -voicerecord rather then +voicerecord, you should fix it.
Meh it doesn't matter, his will work anyways. Because if someone bypasses the mute, they're obviously hacking and therefore get banned anyways.
Sorry, it's been awhile I kinda forgot about this thing. For some reason PlayerBindPress hook doesn't work. Anyways, I tried using yours Faded and I keep getting the error...
bad argument to #2 to '_plyCC' (string expected, got no value)
[lua]
local _runCC = RunConsoleCommand;
local _plyCC = _R.Player.ConCommand
function RunConsoleCommand( cmd )
if( cmd == "+voicerecord" ) and LocalPlayer():GetNWBool( "Muted" ) then
return false;
end
return _runCC( cmd );
end
function _R.Player:ConCommand( cmd )
if( cmd == "+voicerecord" ) and LocalPlayer():GetNWBool( "Muted" ) then
return false;
end
return _plyCC( cmd );
end
[/lua]
You need to supply a 'self' argument in the _plyCC function because when you use a . in your metatable functions, they need a player argument for some reason.
Okay, so return self:_plyCC ??
Or _plyCC(self, cmd), yes. It's the exact same thing, really.
EDIT: Actually I don't think self:_plyCC would work since that would look for a _plyCC method in the object "self", if I'm right. I would use _plyCC(self, cmd).
If you want to use true voice muting, you want to use [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1bc4.html?title=Gamemode.PlayerCanHearPlayersVoice[/url] and not the terrible clientside version which can be overwritten.
Thanks, that's a much better and simpler idea!
[editline]25th March 2012[/editline]
I have a question though, to make it so everyone can hear everyone except people with GetNWBool( "Muted" ) I would do
return ( !plTwo:GetNWBool( "Muted" ) )
.. right?
Nvm, I confirmed it. Thanks for the link!
Sorry, you need to Log In to post a reply to this thread.