how to make a top 5
#1

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
Reply
#2

I just recently made this, so I know you didn't do a search for it

pawn Код:
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]--;
}
If you want to use this, you need to create 2 variables to fill it, example
pawn Код:
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;
    }
}
Reply
#3

Thanks allot! I really appreciate this
As for the searching, i posted this from my mobile and can't get earlyer than tomorrow morning on my computer
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)