ULX disallow target

How would I be able to make it so that a in the targeting parameters for the ranks, I’d be able to put both !%admin and !%moderator in there? I’ve tried myself and failed. Thank you in advance to any people that contribute their time and support :slight_smile:

Make admin inherit from moderator, then do !%admin. this means they can’t target admin or anything below it.

I believe that when you put !%admin in there. Anyone who has a rank lower than admin cannot target users above that user group.

So for example if you wanted moderators to not be able to target admins and above, you would type:

[lua]CanTarget: !%admin[/lua]

Is that what you’re trying to say?

**Edit:**Ninja’d

Thing is, mod does not inherit from admin or vise versa since when I’m changing permissions, they generally change the inherited ranks permissions to which means I waste a while changing permissions so I was looking to see if there was a way to enter multiple variables (if that’s the right word)

I’d say add a helper function like this:

[lua]//
// Checks to see if self > target in terms of admin power. - Josh ‘Acecool’ Moser
//
function PLAYER:IsHigherLevel( target )
if ( !IsValid( target ) && !isnumber( target ) ) then return false; end

if ( isnumber( target ) ) then
	if ( self:GetAccessLevel( ) > target ) then 
		return true;
	end
	
	return false;
end

if ( target:IsPlayer( ) ) then
	if ( self:GetAccessLevel( ) > target:GetAccessLevel( ) || !target:IsAdmin( ) ) then 
		return true;
	end

	return false;
end

end[/lua]

Where GetAccessLevel returns 0 for guest, 1 for member, 100 for vip, 1000 for training moderator, 1001 for game moderator, 1002 for admin, 1003 for senior admin, 2000 for super admin, 2001 for senior super admin, 3000 for dev, 9000 for owner.

Of course, they can be in any order you want. I’d recommend setting up a table of string.lower( ply:GetNWString( “UserGroup” ) ) and binding them to numbers:

[lua]local RankTable = {
player = 1;
admin = 10;
superadmin = 20;
dev = 30;
owner = 40;
}[/lua]

If you store your ranks based on text, you can change those around any time you want and add as many or as few as you want.

For admin actions:
[lua] if ( trace.Entity:IsPlayer( ) && !_p:IsHigherLevel( trace.Entity ) ) then
_p:PrintMessage( HUD_PRINTTALK, language.GetPhrase( “target_ishigherlevel”, _p:GetLanguage( ) ) ); //);
return;
else
// Allow the admin action
end[/lua]

I have no idea how to incorporate this xD

You might be able to string multiple groups together like “!%admin,!%moderator”, but the comma is parsed as a union operator, rather than an intersection, so it probably won’t work like you think. See here for somewhat technical gobbledygook.

Ideally it is best to set up your groups to follow a single line of inheritance, however, you can use the # operator in your case. Namely, % targets groups while following inheritance (in the default group setup, %admin would target both admin and superadmin groups, since superadmin is inherited from admin). Using # will target a single group while ignoring inheritance (#admin will target only admin group).

Megiddo recommends using the # group operator as a workaround- specify the groups you want allowed rather than the ones you don’t want allowed. Like so:
#user,#moderator,#donator