hey how to make top 5
#6

UNTESTED, I'm NOT SURE IF IT'll WORK
pawn Code:
#include <a_samp>

new top5[5][2];

stock GetP1()
{
    new HighestScore = cellmin, LastHighest = INVALID_PLAYER_ID;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(GetPlayerScore(i) > HighestScore){
            HighestScore = GetPlayerScore(i);
            LastHighest = i;
        }
    }
    return top5[0][0] = LastHighest, top5[0][1] = HighestScore;
}

stock GetP2()
{
    new HighestScore = cellmin, LastHighest = INVALID_PLAYER_ID;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if((GetPlayerScore(i) > HighestScore) && (GetPlayerScore(i) < top5[0][1])){
            HighestScore = GetPlayerScore(i);
            LastHighest = i;
        }
    }
    return top5[1][0] = LastHighest, top5[1][1] = HighestScore;
}

stock GetP3()
{
    new HighestScore = cellmin, LastHighest = INVALID_PLAYER_ID;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if((GetPlayerScore(i) > HighestScore) && (GetPlayerScore(i) < top5[1][1])){
            HighestScore = GetPlayerScore(i);
            LastHighest = i;
        }
    }
    return top5[2][0] = LastHighest, top5[2][1] = HighestScore;
}

stock GetP4()
{
    new HighestScore = cellmin, LastHighest = INVALID_PLAYER_ID;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if((GetPlayerScore(i) > HighestScore) && (GetPlayerScore(i) < top5[2][1])){
            HighestScore = GetPlayerScore(i);
            LastHighest = i;
        }
    }
    return top5[3][0] = LastHighest, top5[3][1] = HighestScore;
}

stock GetP5()
{
    new HighestScore = cellmin, LastHighest = INVALID_PLAYER_ID;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if((GetPlayerScore(i) > HighestScore) && (GetPlayerScore(i) < top5[3][1])){
            HighestScore = GetPlayerScore(i);
            LastHighest = i;
        }
    }
    return top5[4][0] = LastHighest, top5[4][1] = HighestScore;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/top5")){
        new str[128], pName[5][MAX_PLAYER_NAME];
        GetP1();
        GetP2();
        GetP3();
        GetP4();
        GetP5();
        GetPlayerName(top5[0][0], pName[0], MAX_PLAYER_NAME);
        GetPlayerName(top5[1][0], pName[1], MAX_PLAYER_NAME);
        GetPlayerName(top5[2][0], pName[2], MAX_PLAYER_NAME);
        GetPlayerName(top5[3][0], pName[3], MAX_PLAYER_NAME);
        GetPlayerName(top5[4][0], pName[4], MAX_PLAYER_NAME);
        format(str, 128, "Nr.1: %s || Nr.2: %s || Nr.3: %s || Nr.4: %s || Nr.5: %s", pName[0], pName[1], pName[2], pName[3], pName[4]);
        SendClientMessageToAll(0xFFFFFFAA, str);
    }
    return 1;
}
I'm sure it can be made shorter, and better. But this is just a fast one. Try it . Atleast it doesn't give any warnings or errors. Do ingame the command /top5
Reply


Messages In This Thread
hey how to make top 5 - by Bilawal2050 - 23.04.2011, 06:10
Re: hey how to make top 5!!! - by GangsTa_ - 23.04.2011, 06:12
Re: hey how to make top 5!!! - by Bilawal2050 - 23.04.2011, 06:13
Re: hey how to make top 5!!! - by GangsTa_ - 23.04.2011, 06:17
Re: hey how to make top 5!!! - by Bilawal2050 - 23.04.2011, 06:18
Re: hey how to make top 5!!! - by Kwarde - 23.04.2011, 06:39
Re: hey how to make top 5!!! - by Bilawal2050 - 23.04.2011, 06:40
Re: hey how to make top 5!!! - by Salsa - 23.04.2011, 06:42
Re: hey how to make top 5!!! - by Salsa - 23.04.2011, 07:12
Re: hey how to make top 5!!! - by wheelman_WM - 23.04.2011, 13:31

Forum Jump:


Users browsing this thread: 1 Guest(s)