07.01.2011, 19:18
I want to make a top 5 but i have no idea on how to do that.
It should be top 5 on players score
I hope someone can help me
It should be top 5 on players score
I hope someone can help me
stock GetTopScores(Players[6],Scores[6]) //This is how many numbers you want + 1 (Ex, you want 5 players, place 6)
{
new tmpscore[2];
new tmpplayer[2];
for(new player;player<MAX_PLAYERS;player++)
{
if(!IsPlayerConnected(player))continue;
tmpscore[0]=GetPlayerScore(player);
tmpplayer[0]=player+1;
for(new spot;spot<sizeof(Players)-1;spot++)
{
if(Scores[spot]<tmpscore[0])
{
if(Scores[sizeof(Scores)-2])
{
Scores[sizeof(Scores)-2]=0;
Players[sizeof(Players)-2]=0;
}
strins(Scores,tmpscore,spot);
strins(Players,tmpplayer,spot);
spot=sizeof(Players);
}
}
}
for(new set;set<sizeof(Players);set++)Players[set]--;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
if(!strcmp("/bestscores",cmdtext,true))
{
new players[6]; //same size as in the function header
new scores[6];
new string[32];
GetTopScores(players,scores);
for(new player;player<5;player++)//same size as in the function header - 1
{
if(players[player]==INVALID_PLAYER_ID)continue;
GetPlayerName(players[player],string,24);
format(string,32,"%s -- %d",string,scores[6]);
SendClientMessage(playerid,0xFFFF00FF,string);
}
return 1;
}
}