How to make a top score???
#7

pawn Code:
new List[MAX_PLAYERS][2];
new count;
for(new i=0; i < MAX_PLAYERS; i++)
{
  if(IsPlayerConnected(i))
  {
    List[count][0] = i;
    List[count][1] = GetPlayerScore(i);
    count++;
  }
}
This code will create a list of all playerid's connected and also saves their score.

pawn Code:
new done, temp;
do
{
  done = 1;
  for(new i=0; i < count-1; i++)
  {
    if(List[i][1] < List[i+1][1])
    {
      done = 0;
      temp = List[i][0];
      List[i][0] = List[i+1][0];
      List[i+1][0] = temp;
      temp = List[i][1];
      List[i][1] = List[i+1][1];
      List[i+1][1] = temp;
    }
  }
}
while(!done);
This code will sort the list until it's in order, so the result will look like this:


place playeridscore
1List[0][0] List[0][1]
2List[1][0]List[1][1]
3List[2][0]List[2][1]

... and so on.
Reply


Messages In This Thread
How to make a top score??? - by NitroSWA - 17.06.2010, 18:15
Re: How to make a top score - by randomkid88 - 17.06.2010, 18:18
Re: How to make a top score - by NewTorran - 17.06.2010, 18:20
Re: How to make a top score - by NitroSWA - 17.06.2010, 18:24
Re: How to make a top score??? - by randomkid88 - 17.06.2010, 18:32
Re: How to make a top score??? - by NitroSWA - 17.06.2010, 18:35
Re: How to make a top score??? - by MadeMan - 17.06.2010, 20:12
Re: How to make a top score??? - by NitroSWA - 17.06.2010, 21:00
Re: How to make a top score??? - by MadeMan - 17.06.2010, 21:16
Re: How to make a top score??? - by luckieluuk - 17.06.2010, 21:54

Forum Jump:


Users browsing this thread: 1 Guest(s)