Hello, I am having this issue where I can’t for the love of me figure out who to easily combine these two custom checks without causing issues.
The two custom checks are listed below and I would appreciate if any of you could help me figure out a way to do it.
Thanks in advance.
customCheck = function(ply) return table.HasValue({“trooper”}, ply:GetNWString(“usergroup”)) end
table.HasValue returns true or false, so we can just use the and operator to tell us if they are both true, otherwise it will be false.
For example:
[lua]–where x is true and y is true
function() return x and y end --returns true, because: true && true == true
–where x is false and y is true
function() return x and y end --return false, because false && true == false (if it was true && false, this would still be the same case)
–where x is false and y is false
function () return x and y end --return false, because false && false == false[/lua]
So if you have two functions (table.HasValue) that give you true or false, you should be able to figure out how to combine the two, similar to above.
Check out truth tables for more info on how that logic works.
This does look very helpful, however I have many different jobs with many different ulx groups assigned to them. There is a donation option for a second character but the owner wanted to switch over to using ulx groups rather than a whitelisting system for the jobs. I don’t believe the above would work properly with many different groups, for ex;
You would create a new table every time and put it above your job table declaration. Ex.
local tAllowedGroups = {
trooper = true
}
-- In first jobtable
customCheck = function(pPlayer)
return (tAllowedGroups[pPlayer:GetUserGroup()] or tAllowedGroups[pPlayer:GetSecondaryUserGroup()]) == true
end
local tAllowedGroups = {
somegroup = true,
somegroup2 = true
}
-- In second jobtable
customCheck = function(pPlayer)
return (tAllowedGroups[pPlayer:GetUserGroup()] or tAllowedGroups[pPlayer:GetSecondaryUserGroup()]) == true
end