This will set a players rank based on the number of XP points. ie., if a player has 250 XP points, he would be assigned to Good rank.
PHP Code:
enum Ranks
{
Noob,
Rookie,
Good,
Best,
Pro
}
new const RankXP[ Ranks ][ 2 ] =
{
{ 0 , 100 }, //Noob
{ 101 , 200 }, //Rookie
{ 201 , 300 }, //Good
{ 301 , 400 }, //Best
{ 401 , 999999999 } //Pro
}
new const RankName[ Ranks ][] =
{
"Noob",
"Rookie",
"Good",
"Best",
"Pro"
}
new g_XP[ 33 ] , Ranks:g_PlayerRank[ 33 ];
public SetRank( id )
{
for ( new Ranks:i = Noob ; i <= Pro ; i++ )
{
if ( RankXP[ i ][ 0 ] <= g_XP[ id ] <= RankXP[ i ][ 1 ] )
{
g_PlayerRank[ id ] = i;
break;
}
}
client_print( 0 , print_chat , "XP=%d Rank=%s" , g_XP[ id ] , RankName[ g_PlayerRank[ id ] ] );
}
__________________