[Ajuda] DOF2 Salva password como 8
#1

O meu sistema de registo salva a password do user diferente da inputtext..

Code:
User = CrusherCpt
Password = §
Registado = true
Money = 10000
Score = 0
Admin = 0
Para fazer login tenho de escrever §..

pawn Code:
//==============================REGISTER====================================
    if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            if(strlen(inputtext) < 2)
            {
                new
                    String[128],
                    StringT[129];

                format(String, sizeof(String), "{FFFFFF}Bem-Vindo{F0D50F} %s{FFFFFF}!!", GetName(playerid));
                format(StringT, sizeof(StringT), "__________________________________\n\n{FFFFFF}O user{F0D50F} %s{FFFFFF} nao esta Registado!\n\nA Password tem de ter entre 4 a 35 caracteres..!", GetName(playerid));
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, String, StringT, "Registar", "Sair");
            }
            else
            {
                new
                    Password[64],
                    StringY[128];

                format(StringY, sizeof(StringY), "{FFFFFF}Registas-te o user {F0D50F}'%s' {FFFFFF}com a password {F0D50F}'%s'{FFFFFF}, foste Logado automaticamente!", GetName(playerid), inputtext);
                SendClientMessage(playerid, 0x80FF00AA, StringY);

                format(Password, sizeof(Password), "%s", inputtext);
                PlayerInfo[playerid][pPassword] = Password;


                DOF2_CreateFile(GetConta(playerid));
                //PlayerInfo[playerid][pPassword] = strlen(inputtext);
                DOF2_SetString(GetConta(playerid), "User", GetName(playerid));
                DOF2_SetString(GetConta(playerid), "Password", PlayerInfo[playerid][pPassword]);
                PlayerInfo[playerid][pRegisto] = true;

                PlayerInfo[playerid][pMoney] = 10000;
                PlayerInfo[playerid][pScore] = 0;
                PlayerInfo[playerid][pAdmin] = 0;


                SetPlayerScore(playerid, 0);
                GivePlayerMoney(playerid, 10000);

                DOF2_SaveFile();
                //SalvarConta(playerid);
            }
        }
        else
        {
            SendClientMessage(playerid, Red, "Registro Cancelado.");
            Kick(playerid);
        }
    }



    //==============================LOGIN=======================================
    else if(dialogid == DIALOG_LOGIN)
    {
        if(response)
        {
            if(strlen(inputtext) >= 2)
            {
                if(strcmp(DOF2_GetString(GetConta(playerid), "Password", PlayerInfo[playerid][pPassword]), inputtext, true, 10) == 0)
                {
                    new String1[128],
                        String2[129];

                    format(String1, sizeof(String1), "{FFFFFF}Bem-Vindo {F0D50F} %s{FFFFFF}!!", GetName(playerid));
                    format(String2, 179, "__________________________________\n\n{FFFFFF}O user{F0D50F} %s{FFFFFF} esta Logado e Pronto a Jogar!\n\nBom Jogo!!!", GetName(playerid));
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_MSGBOX, String1, String2, "Ok", "");

                    CarregarConta(playerid);
                    //SpawnPlayer(playerid);
                }
                else
                {
                    new String[126],
                        StringT[127];

                    format(String, sizeof(String), "{FFFFFF}Bem-Vindo {F0D50F} %s{FFFFFF}!!", GetName(playerid));
                    format(StringT, 179, "__________________________________\n\n{FFFFFF}O user{F0D50F} %s{FFFFFF} esta Registado!\n\nPassword Errada..!", GetName(playerid));
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, String, StringT, "Login", "Sair");
                }
            }
        }
        else
        {
            SendClientMessage(playerid, Red, "Login Cancelado.");
            Kick(playerid);
        }
    }
pawn Code:
stock SalvarConta(playerid)
{
    if(!DOF2_FileExists(GetConta(playerid))) DOF2_CreateFile(GetConta(playerid));

    DOF2_SetString(GetConta(playerid), "User", GetName(playerid));
    DOF2_SetString(GetConta(playerid), "Password", PlayerInfo[playerid][pPassword]);
    DOF2_SetBool(GetConta(playerid), "Registado", PlayerInfo[playerid][pRegisto]);
    DOF2_SetInt(GetConta(playerid), "Money", GetPlayerMoney(playerid));
    DOF2_SetInt(GetConta(playerid), "Score", GetPlayerScore(playerid));
    DOF2_SetInt(GetConta(playerid), "Admin", PlayerInfo[playerid][pAdmin]);
    DOF2_SaveFile();

    return 1;
}


stock CarregarConta(playerid)
{
    GivePlayerMoney(playerid, DOF2_GetInt(GetConta(playerid), "Money"));
    SetPlayerScore(playerid, DOF2_GetInt(GetConta(playerid), "Score"));
    PlayerInfo[playerid][pAdmin] = DOF2_GetInt(GetConta(playerid), "Admin");
    return 1;
}
Reply
#2

@Bump
Ninguem sabe?
Reply
#3

Assim vai salvar a senha, mas apenas numeros que for digitado na hora de registrar..
pawn Code:
if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            if(strval(inputtext) < 2)
            {
                new
                    String[128],
                    StringT[129];

                format(String, sizeof(String), "{FFFFFF}Bem-Vindo{F0D50F} %s{FFFFFF}!!", GetName(playerid));
                format(StringT, sizeof(StringT), "__________________________________\n\n{FFFFFF}O user{F0D50F} %s{FFFFFF} nao esta Registado!\n\nA Password tem de ter entre 4 a 35 caracteres..!", GetName(playerid));
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, String, StringT, "Registar", "Sair");
            }
            else
            {
                new
                    Password[64],
                    StringY[128];

                format(StringY, sizeof(StringY), "{FFFFFF}Registas-te o user {F0D50F}'%s' {FFFFFF}com a password {F0D50F}'%s'{FFFFFF}, foste Logado automaticamente!", GetName(playerid), inputtext);
                SendClientMessage(playerid, 0x80FF00AA, StringY);

                format(Password, sizeof(Password), "%s", inputtext);
                PlayerInfo[playerid][pPassword] = Password;


                DOF2_CreateFile(GetConta(playerid));
                PlayerInfo[playerid][pPassword] = strval(inputtext);
                DOF2_SetString(GetConta(playerid), "User", GetName(playerid));
                DOF2_SetString(GetConta(playerid), "Password", PlayerInfo[playerid][pPassword]);
                PlayerInfo[playerid][pRegisto] = true;

                PlayerInfo[playerid][pMoney] = 10000;
                PlayerInfo[playerid][pScore] = 0;
                PlayerInfo[playerid][pAdmin] = 0;


                SetPlayerScore(playerid, 0);
                GivePlayerMoney(playerid, 10000);

                DOF2_SaveFile();
                //SalvarConta(playerid);
            }
        }
        else
        {
            SendClientMessage(playerid, Red, "Registro Cancelado.");
            Kick(playerid);
        }
    }



    //==============================LOGIN=======================================
    else if(dialogid == DIALOG_LOGIN)
    {
        if(response)
        {
            if(strlen(inputtext) >= 2)
            {
                if(strcmp(DOF2_GetString(GetConta(playerid), "Password", PlayerInfo[playerid][pPassword]), inputtext, true, 10) == 0)
                {
                    new String1[128],
                        String2[129];

                    format(String1, sizeof(String1), "{FFFFFF}Bem-Vindo {F0D50F} %s{FFFFFF}!!", GetName(playerid));
                    format(String2, 179, "__________________________________\n\n{FFFFFF}O user{F0D50F} %s{FFFFFF} esta Logado e Pronto a Jogar!\n\nBom Jogo!!!", GetName(playerid));
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_MSGBOX, String1, String2, "Ok", "");

                    CarregarConta(playerid);
                    //SpawnPlayer(playerid);
                }
                else
                {
                    new String[126],
                        StringT[127];

                    format(String, sizeof(String), "{FFFFFF}Bem-Vindo {F0D50F} %s{FFFFFF}!!", GetName(playerid));
                    format(StringT, 179, "__________________________________\n\n{FFFFFF}O user{F0D50F} %s{FFFFFF} esta Registado!\n\nPassword Errada..!", GetName(playerid));
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, String, StringT, "Login", "Sair");
                }
            }
        }
        else
        {
            SendClientMessage(playerid, Red, "Login Cancelado.");
            Kick(playerid);
        }
    }
Obs: ainda to procurando um jeito de salvar as letras tmb ..
Reply
#4

Quote:
Originally Posted by Nill.Oliveira
View Post
Assim vai salvar a senha, mas apenas numeros que for digitado na hora de registrar..
pawn Code:
if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            if(strval(inputtext) < 2)
            {
                new
                    String[128],
                    StringT[129];

                format(String, sizeof(String), "{FFFFFF}Bem-Vindo{F0D50F} %s{FFFFFF}!!", GetName(playerid));
                format(StringT, sizeof(StringT), "__________________________________\n\n{FFFFFF}O user{F0D50F} %s{FFFFFF} nao esta Registado!\n\nA Password tem de ter entre 4 a 35 caracteres..!", GetName(playerid));
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, String, StringT, "Registar", "Sair");
            }
            else
            {
                new
                    Password[64],
                    StringY[128];

                format(StringY, sizeof(StringY), "{FFFFFF}Registas-te o user {F0D50F}'%s' {FFFFFF}com a password {F0D50F}'%s'{FFFFFF}, foste Logado automaticamente!", GetName(playerid), inputtext);
                SendClientMessage(playerid, 0x80FF00AA, StringY);

                format(Password, sizeof(Password), "%s", inputtext);
                PlayerInfo[playerid][pPassword] = Password;


                DOF2_CreateFile(GetConta(playerid));
                PlayerInfo[playerid][pPassword] = strval(inputtext);
                DOF2_SetString(GetConta(playerid), "User", GetName(playerid));
                DOF2_SetString(GetConta(playerid), "Password", PlayerInfo[playerid][pPassword]);
                PlayerInfo[playerid][pRegisto] = true;

                PlayerInfo[playerid][pMoney] = 10000;
                PlayerInfo[playerid][pScore] = 0;
                PlayerInfo[playerid][pAdmin] = 0;


                SetPlayerScore(playerid, 0);
                GivePlayerMoney(playerid, 10000);

                DOF2_SaveFile();
                //SalvarConta(playerid);
            }
        }
        else
        {
            SendClientMessage(playerid, Red, "Registro Cancelado.");
            Kick(playerid);
        }
    }



    //==============================LOGIN=======================================
    else if(dialogid == DIALOG_LOGIN)
    {
        if(response)
        {
            if(strlen(inputtext) >= 2)
            {
                if(strcmp(DOF2_GetString(GetConta(playerid), "Password", PlayerInfo[playerid][pPassword]), inputtext, true, 10) == 0)
                {
                    new String1[128],
                        String2[129];

                    format(String1, sizeof(String1), "{FFFFFF}Bem-Vindo {F0D50F} %s{FFFFFF}!!", GetName(playerid));
                    format(String2, 179, "__________________________________\n\n{FFFFFF}O user{F0D50F} %s{FFFFFF} esta Logado e Pronto a Jogar!\n\nBom Jogo!!!", GetName(playerid));
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_MSGBOX, String1, String2, "Ok", "");

                    CarregarConta(playerid);
                    //SpawnPlayer(playerid);
                }
                else
                {
                    new String[126],
                        StringT[127];

                    format(String, sizeof(String), "{FFFFFF}Bem-Vindo {F0D50F} %s{FFFFFF}!!", GetName(playerid));
                    format(StringT, 179, "__________________________________\n\n{FFFFFF}O user{F0D50F} %s{FFFFFF} esta Registado!\n\nPassword Errada..!", GetName(playerid));
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, String, StringT, "Login", "Sair");
                }
            }
        }
        else
        {
            SendClientMessage(playerid, Red, "Login Cancelado.");
            Kick(playerid);
        }
    }
Obs: ainda to procurando um jeito de salvar as letras tmb ..
pawn Code:
PlayerInfo[playerid][pPassword] = Password; // error: 047: array sizes do not match, or destination array is too small
Para salvas letras acho que em vez de Strval й Strlen.. Mas nao funciona :/
Reply
#5

й meio ilario , mas do jeito qe eu fiz ai, salva a senha certinho.
Reply
#6

Pra que variбvel pra salvar a senha? Apaga ela e use assim
Code:
DOF2_SetString(GetConta(playerid),"Password", inputtext);
Se ainda nгo conseguir, estude um dos meus sistemas de registro, estгo na minha lista de trabalhos que estб na minha assinatura.
Reply
#7

@Edit.. Arranjei --"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)