Top5 Players bugs
#10

Try the following:
pawn Код:
public Top5Update()
{
    new
        playerScores[MAX_PLAYERS][rankingEnum],
        index
    ;

    new str[128];

    for(new i; i != MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnectedEx(i) && !IsPlayerNPC(i))
        {
            playerScores[index][player_Score] = Player[i][AliveTime];
            playerScores[index][player_ID] = i;
            index++;
        }
    }

    GetPlayerHighestScores(playerScores, 0, index);

    new score_Text[256] = "~n~";
    for(new id; id < 5; ++id)
    {
        format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d", score_Text, id + 1, GetName(playerScores[id][player_ID]), playerScores[id][player_Score]);

        format(str, 128, "Your Alive Time: %d Sec.", Player[id][AliveTime]);
        TextDrawSetString(AliveTimeTD[id], str);
        TextDrawShowForAllAll(AliveTimeTD[id]);
    }

    TextDrawSetString(TopPlayersList, score_Text);
    TextDrawShowForAll(TopPlayers);//Player(i, TopPlayers);
    TextDrawShowForAll(TopPlayersBG);//Player(i, TopPlayersBG);
    TextDrawShowForAll(TopPlayersList);//Player(i, TopPlayersList);
    return 1;
}

stock GetPlayerHighestScores(array[][rankingEnum], left, right)
{
    new
        tempLeft = left,
        tempRight = right,
        pivot = array[(left + right) / 2][player_Score],
        tempVar
    ;
    while(tempLeft <= tempRight)
    {
        while(array[tempLeft][player_Score] > pivot) tempLeft++;
        while(array[tempRight][player_Score] < pivot) tempRight--;

        if(tempLeft <= tempRight)
        {
            tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
            tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
            tempLeft++, tempRight--;
        }
    }
    if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
    if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
}
Since you are showing the Textdraws to everyone, I've changed it to ShowForAll instead.
Reply


Messages In This Thread
Top5 Players bugs - by Stefand - 11.08.2013, 17:15
Re: Top5 Players bugs - by dEcooR - 11.08.2013, 17:22
Re: Top5 Players bugs - by Stefand - 11.08.2013, 17:27
Re: Top5 Players bugs - by dEcooR - 11.08.2013, 18:14
Re: Top5 Players bugs - by Stefand - 11.08.2013, 20:28
Re: Top5 Players bugs - by -Prodigy- - 11.08.2013, 21:02
Re: Top5 Players bugs - by Stefand - 11.08.2013, 21:07
Re: Top5 Players bugs - by -Prodigy- - 11.08.2013, 21:11
Re: Top5 Players bugs - by Stefand - 11.08.2013, 21:13
Re: Top5 Players bugs - by -Prodigy- - 11.08.2013, 21:19

Forum Jump:


Users browsing this thread: 1 Guest(s)