10 Top Players!
#1

Help me, how to make list 10 top players ?
Reply
#2

May this link helps you.
Reply
#3

Below the includes
pawn Код:
new Text: text_Top5[2];
OnGameModeInit
pawn Код:
SetTimer("Top5", 1000, true);
text_Top5[0] = TextDrawCreate(79.000000, 135.000000, "Leaderboard (Top 5)");
    TextDrawAlignment(text_Top5[0], 2);
    TextDrawBackgroundColor(text_Top5[0], 255);
    TextDrawFont(text_Top5[0], 1);
    TextDrawLetterSize(text_Top5[0], 0.280000, 1.499999);
    TextDrawColor(text_Top5[0], -1);
    TextDrawSetOutline(text_Top5[0], 0);
    TextDrawSetProportional(text_Top5[0], 1);
    TextDrawSetShadow(text_Top5[0], 0);
    text_Top5[1] = TextDrawCreate(16.000000, 135.000000, " ");
    TextDrawBackgroundColor(text_Top5[1], 255);
    TextDrawFont(text_Top5[1], 1);
    TextDrawLetterSize(text_Top5[1], 0.200000, 0.999999);
    TextDrawColor(text_Top5[1], -1);
    TextDrawSetOutline(text_Top5[1], 0);
    TextDrawSetProportional(text_Top5[1], 1);
    TextDrawSetShadow(text_Top5[1], 0);
    TextDrawUseBox(text_Top5[1], 1);
    TextDrawBoxColor(text_Top5[1], 150);
    TextDrawTextSize(text_Top5[1], 143.000000, 20.000000);
OnGameModeExit
pawn Код:
TextDrawDestroy(text_Top5[0]);
    TextDrawDestroy(text_Top5[1]);
pawn Код:
forward Top5(playerid);
public Top5(playerid)
{
    new playerMoney[MAX_PLAYERS][rankingEnum], index;
    for(new i; i != MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i))
        {
            playerMoney[index][player_Money] = GetPlayerMoney(i);
            playerMoney[index++][player_ID] = i;
        }
    }
    GetPlayerHighestMoney(playerMoney, 0, index);
    new Money_Text[256] = "~n~",
        player_Name[20];
    for(new i; i < 5; ++i)
    {
        if(i < index)
        {
            GetPlayerName(playerMoney[i][player_ID], player_Name, sizeof(player_Name));
            format(Money_Text, sizeof(Money_Text), "%s~n~~b~%d. ~w~%s - ~r~%d", Money_Text, i + 1, player_Name, playerMoney[i][player_Money]);
        }
        else
        format(Money_Text, sizeof(Money_Text), "%s~n~~b~%d. ~r~N/A", Money_Text, i + 1);
    }
    TextDrawSetString(text_Top5[1], Money_Text);
    TextDrawShowForAll(text_Top5[0]);
    TextDrawShowForAll(text_Top5[1]);
    return 1;
}
Change it to your preference, this is just an example. Credits to RyDeR`
Reply
#4

Nice !! Affan
Reply
#5

I was got it
i mean on y_ini ?
Reply
#6

I don't know what kind of criterias will you use to class the players, but let's imagine that you own a CnR server, and you want to class the players from the one who got the biggest wanted level to the 10th who got the biggest.

You must first get the wanted level of all player's file, using a for loop. Then, take the var which stores the wanted level of the player (still in the loop), and store it to the first slot of a 10-cells array.
Then, take the second player file, and compare it to the first cell of the array. If it's bigger, then change the values : put the first cell of the array (0) to the second (1) and put the higher var in the first cell (0).

If you haven't understood, I can explain more.
Reply
#7

Who can help me to make 10 Top players! But 10 Top player when the player offline!
i mean read file .ini.
btw i am using y_ini.

when type /top , will show DIALOG_STYLE_MSGBOX and will show 10 top players !

sorry for my bad english -_-
Reply
#8

Do you want leadboard show only for online/connected players?
Reply
#9

Quote:
Originally Posted by ShivRp
Посмотреть сообщение
Do you want leadboard show only for online/connected players?
If you can, please
Reply
#10

Use this.
Just have to change the 5 for a 10 to show the top ten
pawn Код:
for(new i; i < 5; ++i)
        {          
            if(i < index)
            {
                GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
                format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d", score_Text, i + 1, player_Name, playerScores[i][player_Score]);        
            }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)