General > Developers Corner

Group Restrict Autorun script

(1/2) > >>

krooks:
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.


--- Code: ---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)
--- End code ---

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

JamminR:
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

krooks:
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

JamminR:
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.

krooks:
I was trying to edit but I quoted and edited the quote hahahaha!

I'll look into it, thanks again

Navigation

[0] Message Index

[#] Next page

Go to full version