30.04.2013, 21:05
How to get top 5 richest guys on server online?
new first = -1, second = -1, third = -1, fourth = -1, fifth = -1, firstamount, secondamount, thirdamount, fourthamount, fifthamount;
for(i=0;i<MAX_PLAYERS;i++)
{
if(GetPlayerMoney(i)>firstamount)
{
first=i;
}
else if(GetPlayerMoney(i)>secondamount)
{
second=i;
}
else if(GetPlayerMoney(i)>thirdamount)
{
third=i;
}
else if(GetPlayerMoney(i)>fourthamount)
{
fourth=i;
}
else if(GetPlayerMoney(i)>fifthamount)
{
fifth=i;
}
else return 1;
}
new string[30]
SendClientMessage(playerid, COLOUR, "Richest people online now:");
format(string, sizeof(string), "1: %s", GetPlayerName(first);
SendClientMessage(playerid, COLOUR, string);
if(second != -1)
{
format(string, sizeof(string), "2: %s", GetPlayerName(second);
SendClientMessage(playerid, COLOUR, string);
}
if(third != -1)
{
format(string, sizeof(string), "3: %s", GetPlayerName(third);
SendClientMessage(playerid, COLOUR, string);
}
if(fourth != -1)
{
format(string, sizeof(string), "4: %s", GetPlayerName(fourth);
SendClientMessage(playerid, COLOUR, string);
}
if(fifth != -1)
{
format(string, sizeof(string), "5: %s", GetPlayerName(fifth);
SendClientMessage(playerid, COLOUR, string);
}