• Print

Author Topic: Whole new gagged ballgame + ulx listen?  (Read 18 times)

0 Members and 1 Guest are viewing this topic.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Whole new gagged ballgame + ulx listen?
« on: February 19, 2010, 11:31:42 pm »
While starting out this evening in researching and improving our current gag commands using the Gmod functions or hooks previously discussed, I realized that the client side SetMuted command would require some major engineering (at least it seemed to me) to make sure that any NEW person connecting to the server would also get GaggedPlayer:SetMuted() ...
Rather than spend major re-inventing the wheel time, I decided to go with the serverside GM hook "PlayerCanHearPlayersVoice"
So far testing has shown promising results.

ULX chat.lua
Code: [Select]
------------------------------ Gag ------------------------------
function ulx.gagcheck( lstn, talk )
if talk.gagged then
return not talk.gagged
end
end
hook.Add("PlayerCanHearPlayersVoice", "GagCheck", ulx.gagcheck, 15 )

function ulx.gag( calling_ply, target_plys, should_ungag )
for _, v in ipairs( target_plys ) do
v.gagged = not should_ungag
umsg.Start( "ulx_gag", v )
umsg.Bool( not should_ungag )
umsg.End()
end

return true
end
local gag = ulx.command( CATEGORY_NAME, "ulx gag", ulx.gag, "!gag" )
gag:addParam{ type=ULib.cmds.PlayersArg }
gag:addParam{ type=ULib.cmds.BoolArg, invisible=true }
gag:defaultAccess( ULib.ACCESS_ADMIN )
gag:help( "Gag target(s), disables you hearing them speak." )
gag:logString( "#1s gagged #2s" )
gag:setOpposite( "ulx ungag", {_, _, true}, "!ungag" )
gag:oppositeLogString( "#1s ungagged #2s" )
ulx.addToMenu( ulx.ID_MCLIENT, "Gag", "ulx gag" )
ulx.addToMenu( ulx.ID_MCLIENT, "Ungag", "ulx ungag" )

ULX cl_lib.lua
Code: [Select]
function ulx.gagUser( bool )
if bool then
local function gagForce( ply, bind )
if string.find( bind, "+voicerecord" ) then
ULib.tsay ( nil, "[ULX] *** You're gagged. No one else can hear you." )
return true
end
end
hook.Add( "PlayerBindPress", "ULXGagForce", gagForce )
RunConsoleCommand( "-voicerecord" )
else
hook.Remove( "PlayerBindPress", "ULXGagForce" )
end
end

local function rcvGag( um )
local bool = um:ReadBool()
ulx.gagUser( bool )
end
usermessage.Hook( "ulx_gag", rcvGag )

Now, I had a stroke of genius (if I do say so myself)
Though currently using the hook to return false anytime a gagged player speaks... why not create a command for admins to continue listening to the gagged player if they choose?
ulx listen <gagged.player>
-Checks if player.gagged - error if not
-set admin.listening.<gaggedplayer>
Within the PlayerCanHearPlayersVoice hook function, add additional check for admin.listening.<gaggedplayer> and continue on its merry way if listening.
Little adjustment would need to be done to cl_lib too of course.

What do you all think?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Whole new gagged ballgame + ulx listen?
« Reply #1 on: February 19, 2010, 11:52:21 pm »
I think it's a cool idea to have this ability, not sure about using the "ulx listen" command though. Seems like people would be confused by the name and seeing it in the help list. Maybe you should have a menu popup for all admins when someone's gagged? Or maybe a 'stealth' command that doesn't show up in help but is advertised when someone is gagged.
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Whole new gagged ballgame + ulx listen?
« Reply #2 on: February 20, 2010, 12:24:55 am »
Heck, most don't seem to use the console help anyway. Ones who do should be intelligent enough to read "allows you to listen to gagged players" Stealth idea could work I guess.
Not sure I want to tackle any popup menus of any kind.
I'm not sure I'd even add the listen command to the gui menus at all.
GUI menu is where most confusion would occur.

OOoo...shiny...a ULX radio... hey! I need to go post this to the forums..."Listen" does nothing!



"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Whole new gagged ballgame + ulx listen?
« Reply #3 on: February 21, 2010, 12:20:33 pm »
Through an hour or two of actual coding, an hour or two of testing, several bangs of my forehead against my keyboard, and a review by Megiddo, we discovered that while sv_alltalk is enabled, the PlayerCanHearPlayersVoice hook is useless.
alltalk 1 still allows all players to hear all others.

Though there was discussion of overriding it... it's (almost) as hacky as the way we currently override single player voicerecord.
For now, I'm not making any changes to our current gag, which also means my "ulx listen" idea is moot.

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print