Ulysses Stuff > Releases

Gag4Me

(1/2) > >>

Buzzkill:
I saw this https://scriptfodder.com/jobs/view/8053 and a couple other similar requests here and figured I might as well release.  For gamemodes that don't natively support mic gagging (Alien Isolation, Elevator, etc, etc), this provides users with a ulx command to toggle local mic gagging of individuals




--- Code: ---CATEGORY_NAME = "THAB"
function ulx.gag4me( calling_ply, target_plys, should_ungag )
local players = player.GetAll()
if calling_ply.ulx_gagged4me == nil then
calling_ply.ulx_gagged4me = {}
end

for i=1, #target_plys do
local v = target_plys[ i ]

calling_ply.ulx_gagged4me[ v:SteamID() ] = not should_ungag

end

if not should_ungag then
ulx.fancyLogAdmin( calling_ply, true, "#A gagged4me #T", target_plys )
else
ulx.fancyLogAdmin( calling_ply, true, "#A ungagged4me #T", target_plys )
end
end
local gag4me = ulx.command( CATEGORY_NAME, "ulx gag4me", ulx.gag4me, "!gag4me", true )
gag4me:addParam{ type=ULib.cmds.PlayersArg }
gag4me:addParam{ type=ULib.cmds.BoolArg, invisible=true }
gag4me:defaultAccess( ULib.ACCESS_ALL )
gag4me:help( "Gag target (mute mic) for individuals. For gamemodes that don't support mic mute on scoreboard." )
gag4me:setOpposite( "ulx ungag4me", {_, _, true}, "!ungag4me" )

local function gag4meHook( listener, talker )
if listener.ulx_gagged4me == nil then return end

if listener.ulx_gagged4me[talker:SteamID()] then
return false
end
end
hook.Add( "PlayerCanHearPlayersVoice", "ULXGag4Me", gag4meHook )
--- End code ---

MrPresident:
Instead of handling this serverside which could interfere with some gamemode use of that hook, why don't you just handle it with the built-in clientside function?

http://wiki.garrysmod.com/page/Player/SetMuted

This is how the Sandbox scoreboard does it.

Buzzkill:

MrPresident:
oook.

Buzzkill:
In other words -- I have no good answer other than just patterned thinking.   :)

Navigation

[0] Message Index

[#] Next page

Go to full version