ULX

Author Topic: Gag4Me  (Read 5881 times)

0 Members and 1 Guest are viewing this topic.

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Gag4Me
« 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 )

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Gag4Me
« Reply #1 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.

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Gag4Me
« Reply #2 on: April 02, 2016, 11:23:01 AM »

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Gag4Me
« Reply #3 on: April 02, 2016, 01:52:44 PM »
oook.

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Gag4Me
« Reply #4 on: April 02, 2016, 07:43:09 PM »
In other words -- I have no good answer other than just patterned thinking.   :)

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Gag4Me
« Reply #5 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.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Gag4Me
« Reply #6 on: July 04, 2016, 01:26:13 AM »
PlayerInitialSpawn and GetPData.

:)

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Gag4Me
« Reply #7 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.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Gag4Me
« Reply #8 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.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Gag4Me
« Reply #9 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.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.