Overwrite IsAdmin() function


I’ve some base in LUA but i had never overwrite a basic Gmod function.

So here’s my problem,

I have 3 ulx group “admin”, “admin+” and “superadmin”

admin and superadmin are considered like Admin with the IsAdmin function but not the admin+

So there is a way to add the admin+ group inside the “allowed group” in IsAdmin? I think that i can overwrite the function but i prefer to see the basic function to know how it work exactly, is there away to see it ?

Sorry for my english, have a nice day

Just use ply:GetUserGroup()

That will return the player ulx rank, So you can check it on there


you should never try and overwrite a base gmod func.

function IsAdmin(ply)
   if ply:GetUserGroup("admin") or ply:GetUserGroup("superadmin") then 
        return true 
  return false

not a detour but it will do what you said


IsAdmin(player entity)

You should also backup the function before overwriting it :wink:

He’s not overwriting it unless you have already made a function named IsAdmin.

i’m not saving the Player.IsAdmin registry table function, i’m making a _G function

Why don’t you do this?

function IsAdmin(ply)
return ply:GetUserGroup(“admin”) or ply:GetUserGroup(“superadmin”)

but how does that work? don’t we need to check both of them

It’s exactly the same as your code except without the useless if statements.

This, but IsUserGroup instead, and with the admin+ group.


Okey, i found it alone finaly (I think, if i’ve done an error tell me :p) but thanks for your help

For people who want to know how :

=> garrysmod/lua/includes/extensions/player_auth.lua

[lua]function meta:IsAdmin()
if self:IsSuperAdmin() then return true end
if self:IsUserGroup(“admin”) then return true end
if self:IsUserGroup(“thegroupthatyouwanttoadd”) then return true end
return false

I don’t know if it’s “good” to do that ^^’

Its not good. you should use the functions given above, and if you use the plymeta, you should copy the function before editing it.

Of course it’s not good. That’s what I meant -.-

local meta = FindMetaTable("Player")
IsAdminCopy = meta.IsAdmin

function meta:IsAdmin(self) 
  return self:IsUserGroup("admin") or self:IsUserGroup("superadmin")


isn’t that exactly how the GMod function works?

Yes, but he put that as an example on how he could modify it.