Hello,
I wanted to know how do I add to check two groups in ulx that are being inherited by others? As of currently this code is not working.
Thank you.
[CODE] customCheck = function(ply)
if ply:IsValid() then return ply:CheckGroup("VIP") or ply:CheckGroup("VIP Moderator") end
end,
CustomCheckFailMsg = "You do not VIP."[/CODE]
Try IsUserGroup instead of CheckGroup
[CODE] customCheck = function(ply) return table.HasValue({"gold", "diamond", "admin", "superadmin", "communitydirector", "founder"},ply:GetUserGroup()) end,[/CODE]
I use the above and it works very well. I prefer to check for every group instead of inherited ones. Just replace my ranks with yours :P
[QUOTE=GoldTrigger;47427852][CODE] customCheck = function(ply) return table.HasValue({"gold", "diamond", "admin", "superadmin", "communitydirector", "founder"},ply:GetUserGroup()) end,[/CODE]
I use the above and it works very well. I prefer to check for every group instead of inherited ones. Just replace my ranks with yours :P[/QUOTE]
No need to loop over the table like that.
[lua]
local ranks = { ["gold"] = true, ["diamond"] = true, ["admin"] = true, ["superadmin"] = true, ["communitydirector"] = true, ["found"] = true }
customCheck = function( ply ) return ( ranks[ply:GetUserGroup( )] ) end
[/lua]
[QUOTE=Jeezy;47427873]No need to loop over the table like that.
[lua]
local ranks = { ["gold"] = true, ["diamond"] = true, ["admin"] = true, ["superadmin"] = true, ["communitydirector"] = true, ["found"] = true }
customCheck = function( ply ) return ( ranks[ply:GetUserGroup( )] ) end
[/lua][/QUOTE]
Well I guess you learn something everyday. Also, question: Would looping over the table cause noticeable lag?
[QUOTE=GoldTrigger;47427938]Well I guess you learn something everyday. Also, question: Would looping over the table cause noticeable lag?[/QUOTE]
Depends on how many elements you are looping over and your sorting
No not in that function, but everyone here will tell you that you will reach [URL="http://en.wikipedia.org/wiki/Big_O_notation"]O( n ).[/URL] In layman's terms, you shouldn't. It's bad practice, especially when you start having larger tables/start using loops in functions that are called more rapidly.
[QUOTE=GoldTrigger;47427852][CODE] customCheck = function(ply) return table.HasValue({"gold", "diamond", "admin", "superadmin", "communitydirector", "founder"},ply:GetUserGroup()) end,[/CODE]
I use the above and it works very well. I prefer to check for every group instead of inherited ones. Just replace my ranks with yours :P[/QUOTE]
This works extremely well, thank you very much!
Sorry, you need to Log In to post a reply to this thread.