Leaderboard [help?]
#20

add

new kills[MAX_PLAYERS];

on top of your script under includes and defines,


then under
Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    kills[killerid]++; //add this
    return 1;
}

//Then under

public OnPlayerSpawn(playerid) // you can also use onplayerconnect...
{
    new first, second, third, fourth, fifth;
    //make a loop
    for(new i=0;i<MAX_PLAYERS;i++) // This loop will check for the player that has the most kills
    {
        if(kills[i] > kills[first])
        {
            first = i;
        }
    }
    for(new d=0;d<MAX_PLAYERS;d++) // This loop will check for the player that has the second most kills
    {
        if(first == d) continue;
        if(kills[d] > kills[second])
        {
            second = d;
        }
    }
    for(new s=0;s<MAX_PLAYERS;s++) // This loop will check for the player that has the third most kills
    {
        if(first == s || second == s) continue;
        if(kills[s] > kills[third])
        {
            third = s;
        }
    }
    for(new a=0;a<MAX_PLAYERS;a++) // This loop will check for the player that has the fourth most kills
    {
        if(first == a || second == a || third == a) continue;
        if(kills[a] > kills[fourth])
        {
            fourth = a;
        }
    }
    for(new c=0;c<MAX_PLAYERS;c++) // This loop will check for the player that has the fifth most kills
    {
        if(first == c || second == c || third == c || fourth == c) continue;
        if(kills[c] > kills[fifth])
        {
            fifth = c;
        }
    }

    //Now you have the top 5 players with most kills
    /*Variables:
    first - id of the player with most kills
    second - id of the player with second most kills
    third - id of the player with third most kills
    fourth - id of the player with fourth most kills
    fifth - id of the player with fifth most kills
    */
    //Your only job now is to set the string of a textdraw to these 5 players and show it to a player that just connected(playerid)
    return 1;
}
I hope you can understand the code which I just wrote.


You\'re welcome.
Reply


Messages In This Thread
Leaderboard [help?] - by Thanks - 11.06.2017, 21:51
Re: Leaderboard [help?] - by Toroi - 11.06.2017, 21:54
Re: Leaderboard [help?] - by Thanks - 11.06.2017, 21:55
Re: Leaderboard [help?] - by Thanks - 11.06.2017, 22:17
Re: Leaderboard [help?] - by Thanks - 12.06.2017, 00:14
Re: Leaderboard [help?] - by Private200 - 12.06.2017, 00:20
Re: Leaderboard [help?] - by Thanks - 12.06.2017, 00:23
Re: Leaderboard [help?] - by Thanks - 12.06.2017, 01:04
Re: Leaderboard [help?] - by RedRex - 12.06.2017, 09:08
Re: Leaderboard [help?] - by Thanks - 12.06.2017, 17:26
Re: Leaderboard [help?] - by RedRex - 12.06.2017, 22:03
Re: Leaderboard [help?] - by Thanks - 12.06.2017, 22:31
Re: Leaderboard [help?] - by Thanks - 13.06.2017, 18:19
Re: Leaderboard [help?] - by Sew_Sumi - 13.06.2017, 20:40
Re: Leaderboard [help?] - by Thanks - 13.06.2017, 22:14
Re: Leaderboard [help?] - by Sew_Sumi - 14.06.2017, 03:53
Re: Leaderboard [help?] - by Thanks - 14.06.2017, 06:30
Re: Leaderboard [help?] - by CheezIt - 14.06.2017, 06:56
Re: Leaderboard [help?] - by Thanks - 14.06.2017, 09:25
Re: Leaderboard [help?] - by andrejc999 - 14.06.2017, 10:26
Re: Leaderboard [help?] - by Thanks - 14.06.2017, 10:31
Re: Leaderboard [help?] - by Thanks - 14.06.2017, 10:44
Re: Leaderboard [help?] - by andrejc999 - 14.06.2017, 10:47
Re: Leaderboard [help?] - by andrejc999 - 14.06.2017, 10:50
Re: Leaderboard [help?] - by Thanks - 14.06.2017, 21:29
Re: Leaderboard [help?] - by Sew_Sumi - 15.06.2017, 02:03
Re: Leaderboard [help?] - by Thanks - 15.06.2017, 08:10
Re: Leaderboard [help?] - by Thanks - 16.06.2017, 01:03
Re: Leaderboard [help?] - by CheezIt - 16.06.2017, 01:05
Re: Leaderboard [help?] - by Thanks - 16.06.2017, 01:09
Re: Leaderboard [help?] - by CheezIt - 16.06.2017, 04:18

Forum Jump:


Users browsing this thread: 1 Guest(s)