[Ajuda] Comandos e Erros
#8

Tente desta forma:

Код:
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]);
	}
}
OBS: eu nгo testei, apenas adaptei ao seu cуdigo
Reply


Messages In This Thread
Comandos e Erros - by DeusGrego - 29.03.2019, 01:20
Re: Comandos e Erros - by SrBlu - 29.03.2019, 02:59
Re: Comandos e Erros - by XandyMello - 30.03.2019, 01:36
Re: Comandos e Erros - by DeusGrego - 31.03.2019, 23:06
Re: Comandos e Erros - by Felipealves - 31.03.2019, 23:46
Re: Comandos e Erros - by DeusGrego - 31.03.2019, 23:52
Re: Comandos e Erros - by NWDMadara - 01.04.2019, 01:54
Re: Comandos e Erros - by JeffSantos2 - 01.04.2019, 10:31
Re: Comandos e Erros - by NWDMadara - 01.04.2019, 21:35
Re: Comandos e Erros - by JeffSantos2 - 02.04.2019, 01:39
Re: Comandos e Erros - by NWDMadara - 02.04.2019, 03:04

Forum Jump:


Users browsing this thread: 1 Guest(s)