Login problem
#1

Hey guys.
Seems like an error occurred on my register/login system.

Code:
pawn Код:
dcmd_register(playerid, params[])
{
    if(dini_Exists(file) ||  pInfo[playerid][Logged] == 1)
        return SendClientMessage(playerid,Red,"ERROR: You are already registered/logged in.");
    else if(!params[0])
        return SendClientMessage(playerid,Red,"USAGE: /register [password]");
    else if(strlen(params) > 10 || strlen(params) < 4)
        return SendClientMessage(playerid,Red,"ERROR: Current password lengths are between 4 and 10.");

    else
    {
        new password = num_hash(params);
        dini_Create(file);
        pInfo[playerid][Password] = password;
        dini_IntSet(file, "Password", pInfo[playerid][Password]);
        SendClientMessage(playerid, Green,"You are successfuly registered,and logged in,thank you for registering,have fun!");
        pInfo[playerid][Logged] = 1;
    }
    return 1;
}
dcmd_login(playerid, params[])
{
    if(!dini_Exists(file))
        return SendClientMessage(playerid, Red, "ERROR: Please register before you try to login.");
    else if(pInfo[playerid][Logged] == 1)
        return SendClientMessage(playerid, Red, "ERROR: You are already logged-in.");
    else if(!params[0])
        return SendClientMessage(playerid, Red, "USAGE: /login [password]");
    else
    {
        new password = num_hash(params);
        if(pInfo[playerid][Password] == password)
        {
            pInfo[playerid][Logged] = 1;
            return SendClientMessage(playerid, lBlue, "You have successfully logged in to your account.");
        }
        else
        return SendClientMessage(playerid, Red, "ERROR: Incorrect password.");
    }
}
Indentation fucked up? Probably.

Anyway,after I register it successfully hashes the password,but when I try to log-in,it says incorrect password.

I hope you guys can help me solve this one!
Reply
#2

so when they join does it get the password from the file and save it into pInfo[playerid][Password] before they try to login?
Reply
#3

Quote:
Originally Posted by cessil
Посмотреть сообщение
so when they join does it get the password from the file and save it into pInfo[playerid][Password] before they try to login?
Wait,what?

I don't get you,but some confusion occurred in there,but I don't know what.

Edit: I've followed this tutorial:
https://sampwiki.blast.hk/wiki/Creating_...erScript#Login
Reply
#4

It should check in the players text file place, not like that, the player haven't even logged in so I doubt they have loaded any pInfo yet.

I don't know that much of Dini, I'm using MySQL so can't help further on.
Reply
#5

Erm D:
Okay then,maybe anyone else could help?
Reply
#6

before you do the password check (if they match) make sure you get the stored password, i don't see anywhere in your script where you do that
Reply
#7

Where do you save player's password to pInfo[playerid][Password] ?
Reply
#8

dini_IntSet(file, "Password", pInfo[playerid][Password]);

And also in OnPlayerDisconnect.
Reply
#9

pawn Код:
new password = num_hash(params);
if(dini_Int(file, "Password") == password)
Reply
#10

Like this?
pawn Код:
dcmd_login(playerid, params[])
{
    format(file,sizeof(file),PlayerFile,pName(playerid));
    if(!dini_Exists(file))
        return SendClientMessage(playerid, Red, "ERROR: Please register before you try to login.");
    else if(pInfo[playerid][Logged] == 1)
        return SendClientMessage(playerid, Red, "ERROR: You are already logged-in.");
    else if(!params[0])
        return SendClientMessage(playerid, Red, "USAGE: /login [password]");
    else
    {
        new password = num_hash(params);
        if(dini_Int(file, "Password") == password)
        {
            pInfo[playerid][Logged] = 1;
            return SendClientMessage(playerid, lBlue, "You have successfully logged in to your account.");
        }
        else
        return SendClientMessage(playerid, Red, "ERROR: Incorrect password.");
    }
}
Because that didn't work either o.O
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)