Lua Question

I wanna make an if then statement in player.lua to only allow certain classes to be accessed by certain ulx usergroups.

This is what I have:


if t == TEAM_PC and self:IsUserGroup("silver") or t == TEAM_PC and self:IsUserGroup("admin") or t == TEAM_PC and self:IsUserGroup("superadmin") or t == TEAM_PC and self:IsUserGroup("gold") or t == TEAM_PC and self:IsUserGroup("platinum") 
then 
Notify(self, 1, 4, "Access Granted")
end

if t == TEAM_PC and not self:IsUserGroup("silver") then
Notify(self, 1, 4, "You must be at least a Silver Donator to become this class!")
return
end

The only problem is that for some reason, When you are one of the allowed user groups, it displays “Access Granted” and then right after displays “You must be at least a Silver Donator to become this class!”
But your job doesn’t change. When I remove:


or t == TEAM_PC and self:IsUserGroup("admin") or t == TEAM_PC and self:IsUserGroup("superadmin") or t == TEAM_PC and self:IsUserGroup("gold") or t == TEAM_PC and self:IsUserGroup("platinum") 

from my code, It works just fine for only the “silver” usergroup.

Use brackets when you have both ‘or’ and ‘and’ statements in an ‘if condition’. If you don’t set them your condition will most likely not work the way you’d want it to.

Where would i put the brackets then

[lua]if (this and that) or (this and that) then

end[/lua]


if (t == TEAM_PC and self:IsUserGroup("silver") or self:IsUserGroup("admin") 
	or self:IsUserGroup("superadmin") or self:IsUserGroup("gold") or self:IsUserGroup("platinum") ) then 
		Notify(self, 1, 4, "Access Granted")
	else
		Notify(self, 1, 4, "You must be at least a Silver Donator to become this class!")
	return
end

is what I would do.