Score - Ayudita
#1

Hola amigos del samp, me podrian dar una ayuda... de como puedo hacer un sistema de los 10 mejores scores cuando vayan alguna ARENA.. como por ejemplo si entro a la /area1 y voy matando vaya sumando el score solo en ese lugar... y cuando quiera ver los mejores escores de todos en la arena1 usando algun comando por ejemplo /topScore pueda ver quien tiene el score mas alto como la imagen.



Y se ordene del mayor score al menor score como la imagen

Claro logicamente viendo si se desconecta para que no lo tome encuenta.

muchas gracias y saludos
Reply
#2

їQuй sistema de guardado utilizas?
Reply
#3

http://forum.sa-mp.com/showpost.php?...2&postcount=44


Код:
#include <a_samp>

#define DIALOG_SCORE (2016)
#define MAX_SCORE (10)
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);
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext, "/topScore", true))
	{
		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[256] = "\n",
			player_Name[20]
		;
		for(new i; i < MAX_SCORE; ++i)
		{
			if(i < index)
			{
				GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
				format(score_Text, sizeof(score_Text), "%s\n %d. %s - \t%d", score_Text, i + 1, player_Name, playerScores[i][player_Score]);
			}
			else
				format(score_Text, sizeof(score_Text), "%s\n %d. N/A", score_Text, i + 1);
		}
		strins(score_Text, "Nicks\tScore", 0);
		ShowPlayerDialog(playerid, DIALOG_SCORE, DIALOG_STYLE_TABLIST_HEADERS, "ARENA N1", score_Text, "ok", "");
		return 1;
	}
	return 0;
}
Reply
#4

Quote:
Originally Posted by OTACON
Посмотреть сообщение
http://forum.sa-mp.com/showpost.php?...2&postcount=44


Код:
#include <a_samp>

#define DIALOG_SCORE (2016)
#define MAX_SCORE (10)
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);
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext, "/topScore", true))
	{
		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[256] = "\n",
			player_Name[20]
		;
		for(new i; i < MAX_SCORE; ++i)
		{
			if(i < index)
			{
				GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
				format(score_Text, sizeof(score_Text), "%s\n %d. %s - \t%d", score_Text, i + 1, player_Name, playerScores[i][player_Score]);
			}
			else
				format(score_Text, sizeof(score_Text), "%s\n %d. N/A", score_Text, i + 1);
		}
		strins(score_Text, "Nicks\tScore", 0);
		ShowPlayerDialog(playerid, DIALOG_SCORE, DIALOG_STYLE_TABLIST_HEADERS, "ARENA N1", score_Text, "ok", "");
		return 1;
	}
	return 0;
}
woo gracias, y ese conteo de score es global con todos los users? pero si quisiera saber los 10 mejores scores de /minigun como podria hacerlo?


saludos
Reply
#5

Si usas sqlite o mysql podrнas hacerlo mбs fбcil, si no usa el que pasaron
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)