I try to set up the targeting system with my server. I have, in order: User, respected, t-mod, moderator, admin, superadmin, Co-Owner, Owner
I don't know how to make it so that they can only taget themselves and people below. I have tried putting admin can target: admin moderator t-mod respected user
that doesn't work
Then I tried admin can target !%superadmin
that doesn't work
how do I do it.
Associate the ranks with numbers, then you can do something like this:
[code]//
// Checks to see if self > target in terms of admin power. - Josh 'Acecool' Moser
//
function META_PLAYER:IsHigherLevel( _t )
if ( !IsValid( _t ) && !isnumber( _t ) ) then return false; end
// Disable IsHigherLevel if the player is frozen ( So if a bad admin is frozen, they can't kickall, etc... )
if ( self.IsFrozen && self:IsFrozen( ) ) then return false; end
// Allow numerical input; compares the current player access level against the numerical value
if ( isnumber( _t ) ) then
if ( self.GetAccessLevel && self:GetAccessLevel( ) > _t ) then
return true;
end
return false;
end
// Allow player entity input; compares the current player access level vs input player. IsHigherLevel returns true for self.
if ( _t:IsPlayer( ) ) then
if ( ( self.GetAccessLevel && self:GetAccessLevel( ) > _t:GetAccessLevel( ) ) || ( self:IsAdmin( ) && !_t:IsAdmin( ) ) || ( self == _t ) ) then
return true;
end
return false;
end
end[/code]
where GetAccessLevel returns the users rank number. Higher number means higher level. The Frozen part is so if a lower level admin is trying to kick / ban everyone, they lose their privileges while frozen. You may or may not want that. I also added support for number being used instead of player...
so: if ( _p:IsHigherLevel( Entity( x ) ) or ( _p:IsHigherLevel( 9000 ) ) ... where _p is the player you're who wants to do the action and 9000 is the user-level or Entity( x ) is the other player object to compare _p to.
[QUOTE=Acecool;47225745]Associate the ranks with numbers, then you can do something like this:
[code]//
// Checks to see if self > target in terms of admin power. - Josh 'Acecool' Moser
//
function META_PLAYER:IsHigherLevel( _t )
if ( !IsValid( _t ) && !isnumber( _t ) ) then return false; end
// Disable IsHigherLevel if the player is frozen ( So if a bad admin is frozen, they can't kickall, etc... )
if ( self.IsFrozen && self:IsFrozen( ) ) then return false; end
// Allow numerical input; compares the current player access level against the numerical value
if ( isnumber( _t ) ) then
if ( self.GetAccessLevel && self:GetAccessLevel( ) > _t ) then
return true;
end
return false;
end
// Allow player entity input; compares the current player access level vs input player. IsHigherLevel returns true for self.
if ( _t:IsPlayer( ) ) then
if ( ( self.GetAccessLevel && self:GetAccessLevel( ) > _t:GetAccessLevel( ) ) || ( self:IsAdmin( ) && !_t:IsAdmin( ) ) || ( self == _t ) ) then
return true;
end
return false;
end
end[/code]
where GetAccessLevel returns the users rank number. Higher number means higher level.[/QUOTE]
What file is this in and what does this do?
It serves as an example. It uses another custom function where GetAccessLevel returns the rank "number" where higher = more "power"...
META_PLAYER = FindMetaTable( "Player" );
[QUOTE=Acecool;47225774]It servers as an example. It uses another custom function where GetAccessLevel returns the rank "number" where higher = more "power"...
META_PLAYER = FindMetaTable( "Player" );[/QUOTE]
Nope, I don't understand, isn't there another way to do it, through the !menu?
You're going to need to create a way to do it, I suggested you convert ranks to numbers ( use a table where each rank is a key and you assign a number as the value.. owner would be the highest number on the list, user or guest would be the lowest ). Then you use a helper-function to read the list, the group, etc so you don't need to add lines of code, or whatever, each time you want to see if a user can do an action against another player.
So, in your menu, all you'd need to do is see if the person using the menu as _p can target a player as ply and you can set up a function in the player meta-table to do it so _p:IsHigherLevel( ply ); will return true if _p is higher level than ply or false if not.. so if true then perform action, if false don't...
[QUOTE=Acecool;47225810]You're going to need to create a way to do it, I suggested you convert ranks to numbers ( use a table where each rank is a key and you assign a number as the value.. owner would be the highest number on the list, user or guest would be the lowest ). Then you use a helper-function to read the list, the group, etc so you don't need to add lines of code, or whatever, each time you want to see if a user can do an action against another player.
So, in your menu, all you'd need to do is see if the person using the menu as _p can target a player as ply and you can set up a function in the player meta-table to do it so _p:IsHigherLevel( ply ); will return true if _p is higher level than ply or false if not.. so if true then perform action, if false don't...[/QUOTE]
I am asking for a lot here but plz can you help me do it?
[QUOTE=Acecool;47225810]You're going to need to create a way to do it, I suggested you convert ranks to numbers ( use a table where each rank is a key and you assign a number as the value.. owner would be the highest number on the list, user or guest would be the lowest ). Then you use a helper-function to read the list, the group, etc so you don't need to add lines of code, or whatever, each time you want to see if a user can do an action against another player.
So, in your menu, all you'd need to do is see if the person using the menu as _p can target a player as ply and you can set up a function in the player meta-table to do it so _p:IsHigherLevel( ply ); will return true if _p is higher level than ply or false if not.. so if true then perform action, if false don't...[/QUOTE]
he's using ulx
I'm not too familiar with how their permission system works, but the system to check level is straight-forward:
[code]//
// Each level should be added to this table, all lowercase. If it has spaces use:
// [ "blah blah" ] = 1234;
//
local UserLevelsTable = {
owner = 9000;
superadmin = 3000;
admin = 1000;
user = 1;
guest = 1;
default = 0;
};
//
// PlayerMeta-table
//
local META_PLAYER = FindMetaTable( "Player" );
//
// Return the user group level value, or use the default number... 0
//
function META_PLAYER:GetUserGroupLevel( _t )
return UserLevelsTable[ string.lower( self:GetUserGroup( ) ) ] || UserLevelsTable.default;
end
//
// Used to see if a player can target another player or perform actions on another player, can use the numbers in the table, or a player as an argument.
//
function META_PLAYER:IsHigherLevel( _t )
// If the target is valid, and a player...
if ( IsValid( _t )&& _t:IsPlayer( ) ) then
return self:GetUserGroupLevel( ) > _t:GetUserGroupLevel( );
elseif ( isnumber( _t ) ) then
// If valid, not valid, whatever but a number...
return self:GetUserGroupLevel( ) > _t;
end
// Default
return false;
end
[/code]
Then just use:
[code]_p:IsHigherLevel( ply );[/code]
or
[code]_p:IsHigherLevel( 1000 );[/code]
where _p is the admin trying to perform the action, and ply is the target player, or 1000 is the target user level number ( in the table )
[QUOTE=Acecool;47225959]I'm not too familiar with how their permission system works, but the system to check level is straight-forward:
[code]//
// Each level should be added to this table, all lowercase. If it has spaces use:
// [ "blah blah" ] = 1234;
//
local UserLevelsTable = {
owner = 9000;
superadmin = 3000;
admin = 1000;
user = 1;
guest = 1;
default = 0;
};
//
// PlayerMeta-table
//
local META_PLAYER = FindMetaTable( "Player" );
//
// Return the user group level value, or use the default number... 0
//
function META_PLAYER:GetUserGroupLevel( _t )
return UserLevelsTable[ string.lower( self:GetUserGroup( ) ) ] || UserLevelsTable.default;
end
//
// Used to see if a player can target another player or perform actions on another player, can use the numbers in the table, or a player as an argument.
//
function META_PLAYER:IsHigherLevel( _t )
// If the target is valid, and a player...
if ( IsValid( _t )&& _t:IsPlayer( ) ) then
return self:GetUserGroupLevel( ) > _t:GetUserGroupLevel( );
elseif ( isnumber( _t ) ) then
// If valid, not valid, whatever but a number...
return self:GetUserGroupLevel( ) > _t;
end
// Default
return false;
end
[/code]
Then just use:
[code]_p:IsHigherLevel( ply );[/code]
or
[code]_p:IsHigherLevel( 1000 );[/code]
where _p is the admin trying to perform the action, and ply is the target player, or 1000 is the target user level number ( in the table )[/QUOTE]
what file is this in?
That would be a SHARED realm file so that either SERVER or CLIENT files can call it.
Can you show us the menu you're changing and how far you've gotten?
Sorry, you need to Log In to post a reply to this thread.