Login system not saving password (+REP)
#1

I made a login system using dialogs and YINI. All of the sudden, when I try to log in, it always shows "Incorrect Password", no matter what I do. I tried entering the UDB hash into the password, but nothing seems to work.

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
    //Login System
    if(dialogid == DIALOG_REGISTER)
        {
        if (!response) return Kick(playerid);
        if(response)
            {
            new INI:File = INI_Open(UserPath(playerid));
            INI_SetTag(File,"Player Info");
            INI_WriteInt(File,"Password",udb_hash(inputtext));
            INI_WriteInt(File, "Paycheck", PlayerInfo[playerid][pPaycheck]);
            INI_WriteInt(File, "Level", PlayerInfo[playerid][pLevel]);
            INI_WriteInt(File, "Hours", PlayerInfo[playerid][pHours]);
            INI_WriteInt(File, "Job", PlayerInfo[playerid][pJob]);
            INI_WriteFloat(File, "Spawn X",PlayerInfo[playerid][pSpawnX]);
            INI_WriteFloat(File, "Spawn Y",PlayerInfo[playerid][pSpawnY]);
            INI_WriteFloat(File, "Spawn Z",PlayerInfo[playerid][pSpawnZ]);
            INI_WriteInt(File, "Admin",PlayerInfo[playerid][pAdmin]);
            INI_WriteInt(File, "Banned",PlayerInfo[playerid][pBanned]);
            INI_WriteInt(File, "Spawn", PlayerInfo[playerid][pSpawn]);
            INI_WriteInt(File, "Bank", PlayerInfo[playerid][pBank]);
            INI_WriteInt(File, "Food", PlayerInfo[playerid][pFood]);
            INI_WriteInt(File, "Water", PlayerInfo[playerid][pWater]);
            INI_WriteInt(File, "Skin", PlayerInfo[playerid][pSkin]);
            INI_WriteInt(File, "Faction", PlayerInfo[playerid][pFaction]);
            INI_WriteString(File, "Faction Rank", PlayerInfo[playerid][pFrank]);
            INI_WriteInt(File, "Faction Level", PlayerInfo[playerid][pFlevel]);
            INI_Close(File);
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Enter your password below:", "Login", "Cancel");
            return 1;
            }
        }
pawn Код:
if(dialogid == DIALOG_LOGIN)
        {
        if(!response) return Kick(playerid);
        if(response)
            {
            if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                SetSpawnInfo(playerid, 0, 1, 1242.0341,327.7363,19.7555, 0, 0, 0, 0, 0, 0, 0 );
                SpawnPlayer(playerid);
                return 1;
                }
            else
                {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","{FF0000}Error:{FFFFFF} You have entered an incorrect password.\nType your password below to login.","Login","Quit");
                }
            }
        }
And this is the code to the UDB hash

pawn Код:
stock udb_hash(buf[]) { // Credits to DracoBlue
    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;
}
As mentioned in the code, credits to DracoBlue for the udb_hash.

Also, this is made by me, not an edit, just incase it matters for whatever reason.
Reply
#2

do u have this on the top

PHP код:
enum pInfo
{
  
pPass,

Reply
#3

Quote:
Originally Posted by BoU3A
Посмотреть сообщение
...............................
?
Reply
#4

Do you have define path where to read/write, save user accounts?

on player enum do you have

pPass[129], //or some variable for pass? (string 129 is randomly writen)

in OnPlayerConnect do you have reading variable to load user account?

On dialog register do you have INI_WriteString(file, "Password", hash);

On dialog login do you have load user accounts?
Reply
#5

Quote:
Originally Posted by |MadDog|
Посмотреть сообщение
Do you have define path where to read/write, save user accounts?

on player enum do you have

pPass[129], //or some variable for pass? (string 129 is randomly writen)

in OnPlayerConnect do you have reading variable to load user account?

On dialog register do you have INI_WriteString(file, "Password", hash);

On dialog login do you have load user accounts?
Ye ofcourse, like I said, everything loads/saves EXCEPT the password...though I didnt put a strlen in the pass

EDIT: I tried it, the password shows up hashed in the ini file, but it still shows incorrect password unless you hit login. (String is still 0)
Reply
#6

Okay, I dunno what the hell happened, but its working all of the sudden now :P
Reply
#7

That problem is fixed, but now all of the sudden it shows incorrect password for everyone. (I updated the thread so I didnt have to make another :P)
Reply
#8

Ensure you are aware of the fact your password is actually an integer and not a string. Secondly, how does the password look in the user's file?
Reply
#9

Quote:
Originally Posted by Accord
Посмотреть сообщение
Ensure you are aware of the fact your password is actually an integer and not a string. Secondly, how does the password look in the user's file?
I have it set to writeint. In the file, it looks like this:

[Player Info]
Password = 141361701
Paycheck = 56
Level = 1
Hours = 0
Job = 0
Admin = 4
Banned = 0
Spawn = 1
Bank = 0
Food = 86086
Water = 86400
Skin = 2
Faction = 0
Faction Level = 0
Reply
#10

pawn Код:
if(dialogid == DIALOG_LOGIN)
        {
        if(!response) return Kick(playerid);
        if(response)
            {
            if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                SetSpawnInfo(playerid, 0, 1, 1242.0341,327.7363,19.7555, 0, 0, 0, 0, 0, 0, 0 );
                SpawnPlayer(playerid);
                return 1;
                }
            else
                {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","{FF0000}Error:{FFFFFF} You have entered an incorrect password.\nType your password below to login.","Login","Quit");
                }
            }
        }
try this, change
pawn Код:
"LoadUser_%s"
to
pawn Код:
"LoadUser_user"
change it in OnplayerConnect and in the dialog
and the money and score and these things will be loaded by the server C: !
and tell me if works
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)