Code: [Select]
else if ( cmd == "setlevel" )
{
if ( level >= GetCmdLevel( cmd ) )
{
if ( ( args ) && ( numArgs == 2 ) )
{
local plrText = GetTok( args, " ", 1 );
local setLvl = GetTok( args, " ", 2 );
local plr2 = null;
if ( IsNum( plrText ) ) plr2 = FindPlayer( plrText.tointeger() );
else plr2 = FindPlayer( plrText );
if ( plr2 )
{
if ( plr2.ID != plr.ID )
{
if ( GetPlayerLevel( plr2 ) > LVL_UNREGISTERED )
{
if ( setLvl.tointeger() > LVL_UNREGISTERED )
{
if ( setLvl.tointeger() < level )
{
local oldLevel = GetPlayerLevel( plr2 );
if ( oldLevel < level )
{
if ( oldLevel < setLvl.tointeger() )
Message( "Admin " + plr + " has promoted player " + plr2 + " to level " + setLvl );
else
Message( "Admin " + plr + " has demoted player " + plr2 + " to level " + setLvl );
SetPlayerLevel( plr2.Name, setLvl );
}
else MessagePlayer( "You cannot set the level of higher or equal level admins", plr, COL_CMDERROR );
}
else MessagePlayer( "You cannot set a level higher or equal to your own", plr, COL_CMDERROR );
}
else MessagePlayer( "Invalid level", plr, COL_CMDERROR );
}
else MessagePlayer( plr2 + " is not a registered nickname.", plr, COL_CMDERROR );
}
else MessagePlayer( "You cannot set your own level", plr, COL_CMDERROR );
}
else MessagePlayer( "Invalid player", plr, COL_CMDERROR );
}
else MessagePlayer( "Invalid arguments (/setlevel <player> <level>)", plr, COL_CMDERROR );
}
else MessagePlayer( "You must be a level " + GetCmdLevel( cmd ) + " admin to use this command", plr, COL_CMDERROR );
return true;
} // End of 'setlevel' function