General > Developers Corner
[Noob, help needed] ULX God Notify
Fluttershy:
The situation is, I am an administrator for a server that I am hoping to contribute to for the lack of coders (or active ones). The problem is that due to natural human negligence, some of the admins forget to turn off godmode when they are done using it. So it ends up causing problems when they get back to playing In-Character (Did I mention it was a Roleplay server?). As a result, Godmode has been revoked from all administrators (Including superadmins) and most of the staff have gone into an outrage against this. (They claim sethealth doesn't allow for stealthy administration, and that superadmins should have access to this regardless anyway.) So, To satisfy both ends, I come up with a witty idea. "Why don't we just code something to make a compromise?" Well, I was shot down by the owner in that we don't have many coders/active coders, and that he's going to hold his ground about godmode being disabled UNTIL something like that is coded.
So, I have tasked myself with the honor of being the person that codes this compromise, being the one that came up with the idea. Even if I somehow stopped participating in the server, it is a good opportunity for me to learn more about lua, and I would have a copy of this code anyhow.
To begin: I looked at some Garry's Mod code, and looked at the ULX code, and thought a simple idea. "Why don't I use draw.wordbox with an if statement for when godmode is used, so that when godmode is turned on, it says something like "Godmode is enabled! Turn if off when you're done." so that people won't forget to turn off godmode. When godmode is then disabled, the big giant wordbox will disappear and stop annoying the admin. This will allow the owner to let godmode be able to be used again, and choose how to deal with admins that still "abuse" the godmode feature."
What I have done so far, is that I've looked at This for reference, and found something that might suit my need to put text on the screen (and not the chat) that won't go away.
Now I want to reference the ULX godmode function (Which I found by looking through the files and finding fun.lua) in a way so that I can make an if statement for when godmode is turned on. I think I'm supposed to have a hook to when godmode is enabled.
Neku:
To be honest, they should remember to disable it themselves, but I can see why that would be handy.
I have very little experience with visuals in lua, and I probably won't be able to answer most questions regarding drawing.
But I can help in other ways.
As far as I know, there isn't a hook for godmode, so your best bet is to try shoving that into the command itself.
Fluttershy:
All right, well, I'll see to trial and error. Many backups will be made.
Neku:
Oh, I forgot, since it's a function for clients, do
--- Code: ---if CLIENT then
end
--- End code ---
Avoid:
Hello there,
interesting problem you are describing here, I think I have a proper solution to this:
Use the PlayerNoClip hook to grant the admin enabling noclip godmode (serverside), then draw your text box (clientside) when noclip is enabled.
And as Neku told you, there is no hook for GodMode, so I'd go with Noclip instead! - When I find the time to, I will put up some code for you.
Edit: Hopefully you can put it to use, here you go!
--- Code: ---function GM:PlayerNoClip( ply, on )
if not ply:IsAdmin() then return false end
if on then
ply:GodEnable()
else
ply:GodDisable()
end
return true
end
function PaintGodBox()
if LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then return end
draw.WordBox( 8, 5, ScrH() / 2, "Godmode: ON", "DermaDefault", Color(255,100,100,200), Color(255,255,255,255))
end
hook.Add( "HUDPaint", "GodModeBox", PaintGodBox )
--- End code ---
Avoid
Navigation
[0] Message Index
[#] Next page
Go to full version