I want to check if a player is for example a Donator, now if there is another group Donator 2. I want it to check the chain, so if donator 2 is higher than donator I want donator 2 to also have permission, for example:
Does ply:IsUserGroup do this?
if ply:IsUserGroup( "Donator" ) then
--Donator + Higher rank like (Donator2, Admin, Superadmin etc.)
end
So I don’t have to do:
if ply:IsUserGroup( "Donator" ) or ply:IsUserGroup( "Donator2" ) then
--Do stuff
end
I want donator and any other groups higher above the chain to also have access.
I would make a meta function with it doing the if then statements on all the user groups you want and then just call that function whenever you need it.
Example:
[lua]
–The meta function
local meta = FindMetaTable(“Player”)
function meta:IsDonorAndUp()
if self:IsUserGroup(“donator”) or self:IsUserGroup(“donator2”) or self:IsUserGroup(“admin”) then
return true
else
return false
end
end
–Example of it in use
function GM:PlayerSpawn(ply)
if ply:IsDonorAndUp()
then ply:SetHealth(125)
end
end
[/lua]
Thank you for your reply though I didn’t really want to do something like that. Reason being I want to let the user specify what groups they want to have access.
[editline]8th June 2013[/editline]
For the user that gave my reply a dumb “brandonj4”, I don’t want people having to go into the main lua file and change this themselves, that is hard code and very annoying.