SA-MP Forums Archive
y_ini problems.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: y_ini problems.. (/showthread.php?tid=311940)



y_ini problems.. - 2KY - 19.01.2012

I've got an enum;

pawn Код:
enum    pData
{
    Password[64],
        ..
}
new p_Data[MAX_PLAYERS][pData];
And I use this function to load the data..

pawn Код:
public LoadUser_data(playerid,name[],value[])
{
    INI_String( "Password",     p_Data[playerid][Password], 64);
        ..
        return 1;
}
In order to register through a dialog, I do this to write the password to the file..

pawn Код:
format(pTxt, 64, "%s", inputtext);
INI_WriteString(AccountData,    "Password",     pTxt);
and I check if the password is correct by using..
pawn Код:
if(strcmp(inputtext, p_Data[playerid][Password], true) == 0) {
This part does not seem to work (the password is correct check); What's wrong?

EDIT: Here's my entire login dialog if that helps any:

pawn Код:
case d_Login: {
       
            if(!response) {
                SendClientMessage(playerid, COLOR_ERROR, "Sorry! You are required to register before playing!");
                return Kick(playerid);
            }
       
            if(!strlen(inputtext))
                return ShowPlayerDialog(playerid, d_Login, DIALOG_STYLE_PASSWORD, "{009AC9}Welcome back!", "{FFFFFF}Please type your {2A9107}password {FFFFFF}below to access your account information!", "Connect", "Quit");
       
            printf("%s", inputtext);
            if(strcmp(inputtext, p_Data[playerid][Password], true) == 0) {
           
                TogglePlayerSpectating(playerid, 0);
           
                INI_ParseFile(FetchTheirAccountLocation(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                GivePlayerMoney(playerid, p_Data[playerid][Money]);
           
                SetSpawnInfo(playerid, 0, p_Data[playerid][SkinModel], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
            }
            else return ShowPlayerDialog(playerid, d_Login, DIALOG_STYLE_PASSWORD, "{009AC9}Welcome back!", "{FFFF00}You have entered an incorrect password!\n{FFFFFF}Please type your {2A9107}password {FFFFFF}below to access your account information!", "Connect", "Quit");
        }



Respuesta: y_ini problems.. - OPremium - 19.01.2012

You need to load the password before checking if its correct!

pawn Код:
public OnPlayerConnect(playerid)
{
    INI_ParseFile(FetchTheirAccountLocation(playerid), "LoadPass_%s", .bExtra = true, .extra = playerid);
}

public LoadPass_data(playerid,name[],value[])
{
    INI_String("Password", p_Data[playerid][Password], 64);
    return 1;
}
Also... Remember to set "p_Data[playerid][Password]" in your register function if you require them to login after registering

pawn Код:
format(pTxt, 64, "%s", inputtext);
p_Data[playerid][Password] = pTxt;
INI_WriteString(AccountData, "Password", pTxt);



Re: Respuesta: y_ini problems.. - 2KY - 19.01.2012

Quote:
Originally Posted by OPremium
Посмотреть сообщение
You need to load the password before checking if its correct!

pawn Код:
public OnPlayerConnect(playerid)
{
    INI_ParseFile(FetchTheirAccountLocation(playerid), "LoadPass_%s", .bExtra = true, .extra = playerid);
}

public LoadPass_data(playerid,name[],value[])
{
    INI_String("Password", p_Data[playerid][Password], 64);
    return 1;
}
Also... Remember to set "p_Data[playerid][Password]" in your register function if you require them to login after registering

pawn Код:
format(pTxt, 64, "%s", inputtext);
p_Data[playerid][Password] = pTxt;
INI_WriteString(AccountData, "Password", pTxt);
I guess it was the thing you mentioned with the registration. Thank you! +rep