Ulysses
General => Developers Corner => Topic started by: krooks on February 04, 2011, 01:09:09 PM
-
Ok so I asked for help restricting an addon [PAC] in facepunch, and the author gave me this script to place in PAC's lua/autorun folder, and it works great.
hook.Add("PrePACConfigApply", "pac_regulars_only", function(ply, config)
if not (ply:IsUserGroup("local") or ply:IsUserGroup("thief") or ply:IsAdmin() or ply:IsSuperAdmin()) then
return false, "Only regulars and up can use pac!"
end
end)
Now I would like to take this idea and apply it to other addons, like Ragmorph.
Can someone please explain what exactly is going on here?
Is "PrePACConfigApply" something that PAC already has or is that something that is being created with this script here?
Can I just change that string(?) to PreRagmorphConfigApply, and drop it is ragmorph's autorun folder expecting it to work?
Thank you
-
Just from a quick look, I'd educated guestimate that Pre blah blah is a PAC bit of code that this overwrites.
Have your OS "text scan utility" of choice search the text of your lua files in /addons/PAC and see.
EDIT-
And to answer your actual questions..
Pac already has (95% sure), No, No, No
-
LOL thanks for the quick reply, and little lesson.
Sounds like its over my head, then ::) hahaha
I AM, however, pretty proud of some lua hackage I did at work today, I successfully sized down a "pixel" size, and enlarged a painting canvas for a dead addon called gm_paint, then added 10 new colors *pats self on the the back* ;D
-
Pat so hard had to say it twice?
:P
Anyway, Ragmorph, if it already has an admin check of some sort (most do), shouldn't be hard to find that code, add additional checks like you did for pac, and edit.
However, The way the code you got from the original post is nicest way.
You'll most likely not have to re-hack if PAC updates. Only if the hook PAC uses changes names.
-
I was trying to edit but I quoted and edited the quote hahahaha!
I'll look into it, thanks again
-
Whenever looking through G-lua files/addons/whatever you're trying to edit for further checks, use text searches for the following three most common.
(You may already know all three, but just in case)
Player.IsSuperAdmin (http://wiki.garrysmod.com/favicon.ico) (http://wiki.garrysmod.com/?title=Player.IsSuperAdmin)
Player.IsAdmin (http://wiki.garrysmod.com/favicon.ico) (http://wiki.garrysmod.com/?title=Player.IsAdmin)
Player.IsUserGroup (http://wiki.garrysmod.com/favicon.ico) (http://wiki.garrysmod.com/?title=Player.IsUserGroup)
According to the wiki article for IsAdmin, it will return 'true' if the player is a SuperAdmin, so, the code given to you for PAC in your original post shouldn't need the ending IsSuperAdmin check to work. (Optimization of code. .000001ms faster execution perhaps :D)
When searching files for adding additional group checks, I'd stick to IsAdmin.
Edit - BTW, don't actually search for the word 'player'. Use 'IsAdmin'. Player will usually be a variable.