01.04.2019, 10:31
(
Последний раз редактировалось JeffSantos2; 02.04.2019 в 01:43.
)
Tente desta forma:
OBS: eu nгo testei, apenas adaptei ao seu cуdigo
Код:
if(!strcmp(cmdtext, "/recorde", true)) { new Score[MAX_PLAYERS][2], count = 0; //na prбtica o count й um contador de players online for(new i; i != MAX_PLAYERS; i++) if(IsPlayerConnected(i)) Score[count][0] = GetPlayerScore(i), Score[count][1] = i, count++; //Use foreach aqui para ser mais performatico //caso use ou vб usar a foreach, basta substituir "for(new i; i != MAX_PLAYERS; i++) if(IsPlayerConnected(i))" por "foreach(Players, i)" SelectionSort(Score, count); //faz um selection sort pela variбvel bidimensional 'Score' que armazena o Level e o ID dos players SendClientMessage(playerid, Verde, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MATA MATA ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); for(new i; i != 1; i++) { format(string, sizeof(string), "~> O jogador conectado com o level mais alto й: %s (ID %d) (Level: %d).", PlayerName(Score[i][1]), Score[i][1], Score[i][0]); SendClientMessage(playerid, Branco, string); } SendClientMessage(playerid, Verde, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MATA MATA ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); return 1; } #define TrocarPosicao(%0,%1) (%0 ^= %1, %1 ^= %0, %0 ^= %1) stock SelectionSort(var_sort[][], size) { new i, j, aux; for(i = 0; i < (size-1); i++) { aux = i; for(j = (i+1); j < size; j++) if(var_sort[j][0] > var_sort[aux][0]) aux = j; if (i != aux) TrocarPosicao(var_sort[i][0], var_sort[aux][0]), TrocarPosicao(var_sort[i][1], var_sort[aux][1]); } }