MetaTables and UserGroups

Hi. I’m trying to create a meta function to detect the following ranks I put in there. Such as superadmin, or admin. And well, it’s not turning out the way I want. I put k,v pairs to test and see if it does detect the players and there groups properly.
But it just isn’t working. Any help would be greatly appreciated. Here’s what I got so far. Both shared and server side file in code quote below.

Shared side


local meta = FindMetaTable( "Player" )

function meta:IsAdminP()
	self:IsUserGroup("admin")
	self:IsUserGroup("doubleadmin")
	self:IsUserGroup("superadmin")
end

Server side

Using k v to test and see if it’s working.
Which it’s not. >.>


for k,v in pairs(player.GetAll()) do
	if v:IsAdminP() then
		v:Kill()
	end
end

That IsAdminP function doesn’t return anything.

Try something like:



function meta:IsAdminP()

    return self:IsUserGroup( "admin" ) or self:IsUserGroup( "doubleadmin" ) or self:IsUserGroup( "superadmin" )

end


Alternatively



local AdminP = {

    admin = true,
    doubleadmin = true,
    superadmin = true

}

function meta:IsAdminP()

    return AdminP[ self:GetUserGroup() ]

end


[lua]
local meta = FindMetaTable( “Player” )

function meta:IsAdminP()
local admingroups = {“admin”,“doubleadmin”,“superadmin”}

    return table.HasValue( admingroups, self:GetUserGroup() )

end
[/lua]

Should work as well.

Great, well try these out in a few minutes. I’ll be sure to edit/post back once I try it out.

[editline]4th March 2016[/editline]

This one worked well, thank you. I had a feeling return was needed in there, but I just didn’t know out to make it out. Thanks for the help
both of you. =b