[Pedido] Rank dof2 - ini
#8

Exemplo bбsico, mal otimizado mas serve de base... No caso seria um rank de grana e sim, estб em STRCMP pq criei no new.pwn sу pra ver se funcionava.

Код:
new nome[10][MAX_PLAYER_NAME];
new dinheiro[10];

if (strcmp("/teste", cmdtext, true, 10) == 0)
	{
        CheckRanking(playerid);
        new frase[256], frasefinal[512];
        for(new i; i < 10; i++)
        {
            format(frase, sizeof frase, "%d Lugar: %s (R$ %d)\n", i+1, nome[i], dinheiro[i]);
            strcat(frasefinal, frase);
        }
        ShowPlayerDialog(playerid, 25000, DIALOG_STYLE_LIST, "TESTE", frasefinal, "ok", "");
		return 1;
	}
    if (strcmp("/dinheiro", cmdtext, true, 10) == 0)
	{
        GivePlayerMoney(playerid, 20000);
        return 1;
    }

stock CheckRanking(playerid)
{
    new valordele = GetPlayerMoney(playerid), nomedele[32];
    GetPlayerName(playerid, nomedele, 32);


    for(new i; i < 10; i++)
    {
        if(valordele < dinheiro[i] && strcmp(nome[i], nomedele, true) == 0)
            nome[i] = "Ninguem";

        if(i == 0 &&valordele > dinheiro[i])
        {
            format(nome[i], 32, "%s", nomedele);
            dinheiro[i] = GetPlayerMoney(playerid);
        }
        else if(valordele > dinheiro[i] && valordele < dinheiro[i-1])
        {
            format(nome[i], 32, "%s", nomedele);
            dinheiro[i] = GetPlayerMoney(playerid);
        }
    }
}

stock SalvarRanking()
{
    new tmp[32];
    if(!DOF2_FileExists("rank.ini"))
    {
        DOF2_CreateFile("rank.ini");
        for(new i; i < 10; i++)
        {
            format(tmp, sizeof tmp, "Nome_%d", i);
            DOF2_SetString("rank.ini", tmp, "Ninguem");
            format(tmp, sizeof tmp, "Dinheiro_%d", i);
            DOF2_SetInt("rank.ini", tmp, 0);
        }
    }
    else{
    for(new i; i < 10; i++)
    {
        format(tmp, sizeof tmp, "Nome_%d", i);
        DOF2_SetString("rank.ini", tmp, nome[i]);
        format(tmp, sizeof tmp, "Dinheiro_%d", i);
        DOF2_SetInt("rank.ini", tmp, dinheiro[i]);
    } }
    return 1;
}

stock CarregarRanking()
{
    new tmp[32];
    if(DOF2_FileExists("rank.ini"))
    {
        for(new i; i < 10; i++)
        {
            format(tmp, sizeof tmp, "Nome_%d", i);
            format(nome[i], 32, "%s", DOF2_GetString("rank.ini", tmp));
            format(tmp, sizeof tmp, "Dinheiro_%d", i);
            dinheiro[i] = DOF2_GetInt("rank.ini", tmp);
        }
    }
    return 1;
}
Reply


Messages In This Thread
Rank dof2 - ini - by Username1234 - 07.05.2015, 01:46
Re: Rank dof2 - ini - by Username1234 - 07.05.2015, 15:20
Re: Rank dof2 - ini - by LuisFerreira - 07.05.2015, 15:23
Re: Rank dof2 - ini - by Krusheer - 07.05.2015, 17:22
Re: Rank dof2 - ini - by Username1234 - 07.05.2015, 17:27
Re: Rank dof2 - ini - by Krusheer - 07.05.2015, 18:02
Re: Rank dof2 - ini - by Kamper - 07.05.2015, 18:20
Re: Rank dof2 - ini - by GabrielDias_Invision - 07.05.2015, 18:51
Re: Rank dof2 - ini - by Username1234 - 07.05.2015, 20:20
Re: Rank dof2 - ini - by GabrielDias_Invision - 07.05.2015, 20:28

Forum Jump:


Users browsing this thread: 5 Guest(s)