[HELP]Can Not save the passwords..
#1

hello ,i have register/login system using dutils+dini , here is the register one :
pawn Код:
if(dialogid == 1) {
        new file[128], name[MAX_PLAYER_NAME], str[128];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(file, sizeof(file), "LATDM/users/%s.ini", name);
        if(response) {
            if(strlen(inputtext)) {
                dini_Create(file);
                dini_IntSet(file, "pw", num_hash(inputtext));
                dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel]);
                dini_IntSet(file, "VipLevel", PlayerInfo[playerid][VipLevel]);
                dini_IntSet(file, "cash", PlayerInfo[playerid][cash]);
                dini_IntSet(file, "score", PlayerInfo[playerid][score]);
                format(str, sizeof(str), "You are registered as ~r~ %s. Your password is ~r~ %s. /changepass to change it", name, inputtext);
                SendClientMessage(playerid, -1, str);
                PlayerInfo[playerid][score] = dini_Int(file, "score");
                PlayerInfo[playerid][cash] = dini_Int(file, "cash");
                PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
                PlayerInfo[playerid][VipLevel] = dini_Int(file, "VipLevel");
            }
        }
        else {
            Kick(playerid);
        }
    }
whene i register , and i /q + login , it says " wrong password". here is my .ini file :
Код:
pw=0
AdminLevel=0
VipLevel=0
cash=0
score=0
i hope you help me
NB: pw= password , i typed Server in it but in the ini file we find pw=0 ....
Reply
#2

It's
pawn Код:
dini_Set(file, "pw", num_hash(inputtext));
Not
pawn Код:
dini_IntSet(file, "pw", num_hash(inputtext));
because password is string not integer.
Reply
#3

pawn Код:
if(dialogid == 1)
    {
        new file[128], name[MAX_PLAYER_NAME], str[128];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(file, sizeof(file), "LATDM/users/%s.ini", name);
        if(response)
        {
            if(!strlen(inputtext)) return Kick(playerid); //Change it!! return anything you want over here!
            dini_Create(file);
            dini_IntSet(file, "pw", udb_hash(inputtext));
            dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel]);
            dini_IntSet(file, "VipLevel", PlayerInfo[playerid][VipLevel]);
            dini_IntSet(file, "cash", PlayerInfo[playerid][cash]);
            dini_IntSet(file, "score", PlayerInfo[playerid][score]);
            format(str, sizeof(str), "You are registered as ~r~ %s. Your password is ~r~ %s. /changepass to change it", name, inputtext);
            SendClientMessage(playerid, -1, str);
            PlayerInfo[playerid][score] = dini_Int(file, "score");
            PlayerInfo[playerid][cash] = dini_Int(file, "cash");
            PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][VipLevel] = dini_Int(file, "VipLevel");
        }
        else
        {
            Kick(playerid);
        }
    }

    // Add this anywhere in the GM But not in a function!
    /*Credits to Dracoblue*/
    stock udb_hash(buf[])
    {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
    }
Reply
#4

thank you for replying
i edited it to what you said but i got 1 error :
Код:
C:\DOCUME~1\ADMINI~1\Bureau\ALAE\LATDM\GAMEMO~1\LATDM.pwn(559) : error 035: argument type mismatch (argument 3)
Reply
#5

Wait. I saw hash before but now I noticed it better it's num_hash.
Is this only for numeric passwords?
Reply
#6

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
pawn Код:
if(dialogid == 1)
    {
        new file[128], name[MAX_PLAYER_NAME], str[128];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(file, sizeof(file), "LATDM/users/%s.ini", name);
        if(response)
        {
            if(!strlen(inputtext)) return Kick(playerid); //Change it!! return anything you want over here!
            dini_Create(file);
            dini_IntSet(file, "pw", udb_hash(inputtext));
            dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel]);
            dini_IntSet(file, "VipLevel", PlayerInfo[playerid][VipLevel]);
            dini_IntSet(file, "cash", PlayerInfo[playerid][cash]);
            dini_IntSet(file, "score", PlayerInfo[playerid][score]);
            format(str, sizeof(str), "You are registered as ~r~ %s. Your password is ~r~ %s. /changepass to change it", name, inputtext);
            SendClientMessage(playerid, -1, str);
            PlayerInfo[playerid][score] = dini_Int(file, "score");
            PlayerInfo[playerid][cash] = dini_Int(file, "cash");
            PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][VipLevel] = dini_Int(file, "VipLevel");
        }
        else
        {
            Kick(playerid);
        }
    }

    // Add this anywhere in the GM But not in a function!
    /*Credits to Dracoblue*/
    stock udb_hash(buf[])
    {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
    }
Doesn't work
Reply
#7

Quote:
Originally Posted by ServerScripter
Посмотреть сообщение
Doesn't work
Whats the error? [/code it!]
Reply
#8

there are no errors only the password doesn't save i see in my ini file pw=0 (must be '123456' )

must i edite "num" to "udb"?
Reply
#9

Quote:
Originally Posted by ServerScripter
Посмотреть сообщение
there are no errors only the password doesn't save i see in my ini file pw=0 (must be '123456' )

must i edite "num" to "udb"?
yeah and use that stock inside the GM!
Reply
#10

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
yeah and use that stock inside the GM!
i edited but still not working... maybe the problem with Public onplayerdisconnect ? :
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(file, sizeof(file), "LATDM/users/%s.ini", name);
    if(dini_Exists(file)) {
        dini_IntSet(file, "pw", PlayerInfo[playerid][pw]);
        dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel]);
        dini_IntSet(file, "VipLevel", PlayerInfo[playerid][VipLevel]);
        dini_IntSet(file, "cash", PlayerInfo[playerid][cash]);
        dini_IntSet(file, "score", PlayerInfo[playerid][score]);
    }
    return 1;
}
@Dwane: Wait. I saw hash before but now I noticed it better it's num_hash.
Is this only for numeric passwords? oh i don't know
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)