11.03.2016, 13:38
Try this, read comments :
PHP код:
new top3[3] = {-1, ...};//this initilizes the array with all index value set as -1, so the array has -1's in it
top_kills = -1;
new onlinePlayerNumber = 0;
//first getting number of online players
//because if players are less than 3 then get the top 2 or top 1 only.
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)if(IsPlayerConnected(i))onlinePlayerNumber++;
//Getting top 3 and store in top[3] array
for(new num = 0; num < (onlinePlayerNumber > 3 ? 3 : onlinePlayerNumber); num++)
{
for (new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
// here we check if player is already not on list :
if(top[0] != i && top[1] != i && IsPlayerConnected(i))
{
if (PlayerInfo[i][pRoundkills] > top_kills)
{
top[num] = i;
top_kills = PlayerInfo[i][pRoundkills];
}
}
}
top_kills = -1;
}
// task done now just send top 3 message
for(new i = 0; i < 3; i++)
{
//make sure to put this if conditon :
if(top[i] != -1)SendClientMessage(top[i], 0x00cc00FF, "HEY! You are on top 3 list!!");
}