SA-MP Forums Archive
10 Top Players! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: 10 Top Players! (/showthread.php?tid=514662)



10 Top Players! - VenomMancer - 22.05.2014

Help me, how to make list 10 top players ?


Re: 10 Top Players! - Rittik - 22.05.2014

May this link helps you.


Re: 10 Top Players! - Affan - 22.05.2014

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`


Re: 10 Top Players! - GeekSiMo - 22.05.2014

Nice !! Affan


Re: 10 Top Players! - VenomMancer - 22.05.2014

I was got it
i mean on y_ini ?


Re : 10 Top Players! - S4t3K - 22.05.2014

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.


Re: 10 Top Players! - VenomMancer - 03.06.2014

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 -_-


Re: 10 Top Players! - Guest4390857394857 - 03.06.2014

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


Re: 10 Top Players! - VenomMancer - 05.06.2014

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


Re: 10 Top Players! - Onfroi - 05.06.2014

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]);        
            }