Ulysses

Ulysses Stuff => Releases => Topic started by: Buzzkill on April 02, 2016, 08:59:57 AM

Title: Gag4Me
Post by: Buzzkill on April 02, 2016, 08:59:57 AM
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: [Select]
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 )
Title: Re: Gag4Me
Post by: MrPresident on April 02, 2016, 11:08:36 AM
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.
Title: Re: Gag4Me
Post by: Buzzkill on April 02, 2016, 11:23:01 AM
(http://treasure.diylol.com/uploads/post/image/254600/resized_history-channel-alien-guy-meme-generator-why-because-aliens-73ace6.jpg)
Title: Re: Gag4Me
Post by: MrPresident on April 02, 2016, 01:52:44 PM
oook.
Title: Re: Gag4Me
Post by: Buzzkill on April 02, 2016, 07:43:09 PM
In other words -- I have no good answer other than just patterned thinking.   :)
Title: Re: Gag4Me
Post by: Buzzkill on July 03, 2016, 09:19:54 PM
btw -- I do have a reasonable answer after kinda smacking into this.  The client-side, SetMuted version doesn't survive the disconnect/reconnect of the offender.  The current hook approach does.   Now, how valuable that is is debatable, but it is a nice feature that someone can't disconnect/reconnect and skirt the gag4me.
Title: Re: Gag4Me
Post by: MrPresident on July 04, 2016, 01:26:13 AM
PlayerInitialSpawn and GetPData.

:)
Title: Re: Gag4Me
Post by: Buzzkill on July 05, 2016, 10:31:59 PM
That's a fine approach for permagagging someone universally.  However, tracking individual mutes/gags by players, against other players can generate some (potentially) large permutations.  It's a little easier to just track the gag on the issuer's session.
Title: Re: Gag4Me
Post by: Bite That Apple on July 05, 2016, 11:23:49 PM
Personally, I think it would be a better idea to do exactly the same thing with PSetData, serverside, then when player joins it mutes them automatically instead of having it set on PSetData clientside.
Title: Re: Gag4Me
Post by: roastchicken on July 06, 2016, 06:16:20 AM
That's a fine approach for permagagging someone universally.  However, tracking individual mutes/gags by players, against other players can generate some (potentially) large permutations.  It's a little easier to just track the gag on the issuer's session.

What permutations do you have in mind? I can't think of any issues with storing them clientside. The only potential problem I can forsee is if two players frequent the same two (or more) servers and those servers run this addon then the mute will carry, but in my opinion that would be desirable.