Ulysses
General => Developers Corner => Topic started by: EMB 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
-
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.
-
There's supposed to be better functions to do this, but of course, garry broke them a while back and never fixed them.
-
Would this work instead?
http://wiki.garrysmod.com/?title=Gamemode.PlayerStartVoice
-
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.
-
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.
-
http://luabin.foszor.com/code/gamemodes/base/gamemode/cl_voice.lua#29 (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.
-
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:
lua_run_cl hook.Remove( "PlayerBindPress", "ULXGagForce" ) timer.Destroy( "GagLocalPlayer")
-
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)
-
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.
-
The only thing they could do would be remove the hook which they would be banned for (http://forums.ulyssesmod.net/index.php/topic,4563.msg18446.html#msg18447).
At least it is a little less crude than your current system.
BTW, like your sig Megiddo
“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
Software Upgrade Paradox - If you improve a piece of software enough times, you eventually ruin it - David Pogue
-
Hmm.. seems simple enough to just keep kicking them if we don't find the hook on the client side.
-
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?
-
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.
-
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.