Author Topic: How does ulx gag work?  (Read 9709 times)

0 Members and 1 Guest are viewing this topic.

Offline EMB

  • Newbie
  • *
  • Posts: 26
  • Karma: 0
How does ulx gag work?
« on: May 11, 2010, 08:31:25 AM »
I wish to know how you made ulx gag work, as I have trawled through our nice corner and the whole of the ULX folder to no avail.

Sorry if this seems obvious,

EMB

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: How does ulx gag work?
« Reply #1 on: May 11, 2010, 03:21:30 PM »
Quite hackish, involving both client and server.
Server sends client "gagged" boolean using Umsg, client starts function that runs console command -voicerecord every (.3?) seconds.

We'd thought about using CanHearPLayersVoice, but, all talk has to be disabled, and we didn't want to yet again hack around that.
"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: How does ulx gag work?
« Reply #2 on: May 11, 2010, 06:11:38 PM »
There's supposed to be better functions to do this, but of course, garry broke them a while back and never fixed them.
Experiencing God's grace one day at a time.

Offline EMB

  • Newbie
  • *
  • Posts: 26
  • Karma: 0
Re: How does ulx gag work?
« Reply #3 on: May 12, 2010, 08:00:59 AM »
« Last Edit: May 12, 2010, 09:55:41 AM by EMB »

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: How does ulx gag work?
« Reply #4 on: May 12, 2010, 01:33:23 PM »
Returning false doesn't do anything for that function. It's just to let you know when they start talking rather than controlling whether they can or not.
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: How does ulx gag work?
« Reply #5 on: May 12, 2010, 03:45:16 PM »
EMB, though what Jay said is true, your find could still possibly help our gag command.
Right now, when gag is enabled, our function 1) looks for bind pressed involving +voicerecord (and immediately runs -voicerecord) , and 2) runs a .3 second timer constantly -voicerecord 'ing them.
It's possible that the PlayerVoiceStart function would be better than, or at least assist, in the monitoring of +voicerecord bind.
I don't think it was around when I first came up with gag.

[Edit] - I was going to also suggest monitoring/logging of when players speak in our ULX logs, but, it's client side only. Yes, it could still be done with some lua client to server magic, but, that just complicates the reason you want to track.
« Last Edit: May 12, 2010, 03:51:54 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: How does ulx gag work?
« Reply #6 on: May 12, 2010, 09:20:40 PM »
http://luabin.foszor.com/code/gamemodes/base/gamemode/cl_voice.lua#29

It would give you notification and allow you to control the voice gui stuff.
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline RynO-SauruS

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 17
Re: How does ulx gag work?
« Reply #7 on: May 13, 2010, 07:36:03 AM »
The way this currently works, wouldn't it be relatively easy to bypass this and talk when you're gagged?
Just by binding this to a key:
Code: [Select]
lua_run_cl hook.Remove( "PlayerBindPress", "ULXGagForce" ) timer.Destroy( "GagLocalPlayer")
« Last Edit: May 13, 2010, 07:39:28 AM by RynO-SauruS »


YouTube music player by RynO-SauruS

Offline EMB

  • Newbie
  • *
  • Posts: 26
  • Karma: 0
Re: How does ulx gag work?
« Reply #8 on: May 13, 2010, 09:29:39 AM »
Code: [Select]
function PlayerStartVoice( ply )
ply:ConCommand("-voicerecord"
end
hook.Add( "PlayerStartVoice", "Ulx Gag", PlayerStartVoice)

Would something like this work (knocked up on the spot so won't be a final, perfect piece of code)

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: How does ulx gag work?
« Reply #9 on: May 13, 2010, 09:55:25 AM »
Assuming that's one of the lucky hooks that actually functions properly, yes that would work. But it suffers the same limitations that Ryno pointed out above.
Experiencing God's grace one day at a time.

Offline EMB

  • Newbie
  • *
  • Posts: 26
  • Karma: 0
Re: How does ulx gag work?
« Reply #10 on: May 13, 2010, 11:49:08 AM »
The only thing they could do would be remove the hook which they would be banned for.
At least it is a little less crude than your current system.

BTW, like your sig Megiddo
Quote
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” -Brian W. Kernighan
"I love working on my crappy code. it is crappy, but it is mine. I guess I could love other people's code, but it's like loving other people's children -- not quite the same as your own" -- Jeff Atwood

And yours JamminR
Quote
Software Upgrade Paradox - If you improve a piece of software enough times, you eventually ruin it - David Pogue
« Last Edit: May 13, 2010, 11:56:26 AM by EMB »

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: How does ulx gag work?
« Reply #11 on: May 13, 2010, 01:20:06 PM »
Hmm.. seems simple enough to just keep kicking them if we don't find the hook on the client side.
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: How does ulx gag work?
« Reply #12 on: May 13, 2010, 05:51:36 PM »
Re: Bypassing - yes. Relatively easy for people with half a lua brain cell. As EMB found previous discussion (good eye it seems!) , most of us feel banning would be appropriiate for those 'intelligent' enough to bypass. (Yes, intelligence is a relative term)

Gag, if I remember correctly, was an idea I threw in as a last minute to a release, Megiddo improved upon it's overall function, but we didn't spend large amounts of time on it after that. Overall it worked. We've never fully liked the way it work (both due to the somewhat necessary timer and possible explots)
As the post EM8 points out mentions, we'd somewhat recently looked into improving it, but so far no other ideas have seemed as "Simple" as the one we're currently using.
Simplicity is what we strive for.

But, back to original discussion question... EM8... have we answered  your question directly enough?
Do you have more questions? Need directions on where to find our code?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline EMB

  • Newbie
  • *
  • Posts: 26
  • Karma: 0
Re: How does ulx gag work?
« Reply #13 on: May 14, 2010, 08:06:33 AM »
I think you have answered well enough, I just wanted this so that I can make any client not a certain Group or Higher to be unable to use the mic. My own code I have created here, coupled with some stuff I have found while delving into our little corner, will suffice to my needs.

To finalise my ending post I think that you may benefit running something like this as a client Lua file within Ulx, which asks the server wether the player is muted or not and then acts correspondingly. I also think my file may help the community, and so shall release it here when completed and tested for a few weeks.

Note: Spell checker doesn't recognise the word "Lua" or "Ulx". Just to let you know in-case you weren't aware.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: How does ulx gag work?
« Reply #14 on: May 14, 2010, 03:18:40 PM »
I think that you may benefit running something like this as a client Lua file within Ulx, which asks the server wether the player is muted or not and then acts correspondingly
Basically, we already do this.
Admin runs command on client player, client gets sent umsg, umsg = on = local gag or off = no gag.
Though we don't use the PlayerStartvoice command discussed above, it's still as you describe it.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming