24.02.2015, 16:45
(
Последний раз редактировалось best95; 27.02.2015 в 15:10.
)
@REMOVIDO
@_CallBack: MostrarRankPlayer(playerid)
{
new
playerScores[MAX_PLAYERS][rankingEnum],
index
;
for(new i; i != MAX_PLAYERS; ++i)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
playerScores[index][player_Score] = GetPlayerScore(i);
playerScores[index++][player_ID] = i;
}
}
GetPlayerHighestScores(playerScores, 0, index);
new
score_Text[500] = "\n",
player_Name[MAX_PLAYER_NAME]
;
for(new i; i < 10; ++i)
{
if(i < index)
{
GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
format(score_Text, sizeof(score_Text), "%s{FFFFFF}%dє - {1E90FF}%s {FFFFFF}- Score: {FFD700}%d\n", score_Text, i + 1, player_Name, playerScores[i][player_Score]);
}
else
{
format(score_Text, sizeof(score_Text), "%s{FFFFFF}%dє - {1E90FF}Ninguйm\n", score_Text, i + 1);
}
}
ShowPlayerDialog(playerid, DIALOG_MENSAGEM, DIALOG_STYLE_MSGBOX, "{FFFFFF}TOPScore {228B22}20", score_Text, "Fechar", "");
return true;
}
enum rankingEnum
{
player_Score,
player_ID
}
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);
}