Help me please? i really need help
#1

I got this login and register system by Kush and when i register it logs in fine and stuff but when i relog i get the login screen and i type the correct password but it says invalid password please help me.. here is the code

pawn Код:
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;
}
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login on PBRP","Welcome back to PBRP! This account is registered.\nEnter your password below to login to your account.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register on PBRP","Welcome to PBRP! This account is not registered.\nEnter your password below to create the account account.","Register","Quit");
    }
    return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register on PBRP","Welcome to PBRP! This account is not registered.\nEnter your password below to create the account account.","Register","Quit");
            new INI:File = INI_Open(UserPath(playerid));
            INI_SetTag(File,"PBRP User Database");
            INI_WriteInt(File,"Password",udb_hash(inputtext));
            INI_WriteInt(File,"Admin",0);
            INI_WriteInt(File,"Money",0);
            INI_WriteInt(File,"Level",0);
            INI_WriteInt(File,"Skin",0);
            INI_Close(File);
            SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
            SpawnPlayer(playerid);
            SendClientMessage(playerid,-1,"Welcome to PBRP! You have successfully registered.");
        }
        else Kick(playerid);
    }
    else if(dialogid == DIALOG_LOGIN)
    {
        if( response )
        {
            if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
            {
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
                GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
                SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
                SendClientMessage(playerid,-1,"Welcome back to PBRP! You have successfully logged in.");
            }
            else
            {
                ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login on PBRP","Welcome back to PBRP! This account is registered.\nEnter your password below to login to your account.","Login","Quit");
            }
            return 1;
        }
        else Kick(playerid);
    }
    return 1;
}
Reply
#2

Are you sure its being written in the data file?
Reply
#3

I think so, how do i show you it?
Reply
#4

Better use Whirlpool hash instead of udb.
Reply
#5

This should work tho
Change this
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register on PBRP","Welcome to PBRP! This account is not registered.\nEnter your password below to create the account account.","Register","Quit");
            new INI:File = INI_Open(UserPath(playerid));
            INI_SetTag(File,"PBRP User Database");
            INI_WriteInt(File,"Password",udb_hash(inputtext));
            INI_WriteInt(File,"Admin",0);
            INI_WriteInt(File,"Money",0);
            INI_WriteInt(File,"Level",0);
            INI_WriteInt(File,"Skin",0);
            INI_Close(File);
            SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
            SpawnPlayer(playerid);
            SendClientMessage(playerid,-1,"Welcome to PBRP! You have successfully registered.");
        }
        else Kick(playerid);
    }
    else if(dialogid == DIALOG_LOGIN)
    {
        if( response )
        {
            if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
            {
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
                GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
                SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
                SendClientMessage(playerid,-1,"Welcome back to PBRP! You have successfully logged in.");
            }
            else
            {
                ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login on PBRP","Welcome back to PBRP! This account is registered.\nEnter your password below to login to your account.","Login","Quit");
            }
            return 1;
        }
        else Kick(playerid);
    }
    return 1;
}
to this
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register on PBRP","Welcome to PBRP! This account is not registered.\nEnter your password below to create the account account.","Register","Quit");
            new INI:File = INI_Open(UserPath(playerid));
            INI_SetTag(File,"data"); //changed this back to data || Because your INI_ParseFile is "LoadUser_data"
            INI_WriteInt(File,"Password",udb_hash(inputtext));
            INI_WriteInt(File,"Admin",0);
            INI_WriteInt(File,"Money",0);
            INI_WriteInt(File,"Level",0);
            INI_WriteInt(File,"Skin",0);
            INI_Close(File);
            SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
            SpawnPlayer(playerid);
            SendClientMessage(playerid,-1,"Welcome to PBRP! You have successfully registered.");
        }
        else Kick(playerid);
    }
    else if(dialogid == DIALOG_LOGIN)
    {
        if( response )
        {
            if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
            {
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
                GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
                SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
                SendClientMessage(playerid,-1,"Welcome back to PBRP! You have successfully logged in.");
            }
            else
            {
                ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login on PBRP","Welcome back to PBRP! This account is registered.\nEnter your password below to login to your account.","Login","Quit");
            }
            return 1;
        }
        else Kick(playerid);
    }
    return 1;
}
Reply
#6

Thats just a tag :P that has nothing to do with passwords but thanks anyway
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)