Password isn't saved [y_ini]
#1

Password isn't saved


pawn Код:
enum xInfo
{
    xPassword[64],
    xMoney,
    xAdmin
}
new PlayerInfo[MAX_PLAYERS][xInfo];
pawn Код:
public LoadUser_data(playerid,name[],value[])
{
    INI_String("Password", PlayerInfo[playerid][xPassword], 64);
    INI_Int("Cash", PlayerInfo[playerid][xMoney]);
    INI_Int("Admin", PlayerInfo[playerid][xAdmin]);
    return 1;
}
pawn Код:
stock UpdatePlayer(playerid)
{
    if(pLogged{playerid} == true)
    {
        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File,"data");
        INI_WriteString(File,"Password",PlayerInfo[playerid][xPassword]);
        INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
        INI_WriteInt(File,"Admin",PlayerInfo[playerid][xAdmin]);
    INI_Close(File);
    }
    return 1;
}
pawn Код:
case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{800000}Error","{686868}Type a password","Login","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteString(File,"Password",PlayerInfo[playerid][xPassword]);
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_Close(File);
            }
        }
pawn Код:
case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(strlen(inputtext) == PlayerInfo[playerid][xPassword])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    pLogged{playerid} = (true);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][xMoney]);
                    XSetSpawnInfo(playerid);
                    UpdatePlayer(playerid);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
What is wrong? Please somebody fix that. Thanks in advance
Reply
#2

pawn Код:
format(PlayerInfo[playerid][xPassword], 64, "%s", inputtext);

case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{800000}Error","{686868}Type a password","Login","Quit");
                format(PlayerInfo[playerid][xPassword], 64, "%s", inputtext);
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteString(File,"Password",PlayerInfo[playerid][xPassword]);
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_Close(File);
            }
        }
Reply
#3

You aren't setting a value to the PlayerInfo[playerid][xPassword] variable. Therefore, it's going to write a null string.

Therefore, you need to put the contents of inputtext into this variable: PlayerInfo[playerid][xPassword]
Reply
#4

@Glad2BeHere, No, it doesn't work.

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
You aren't setting a value to the PlayerInfo[playerid][xPassword] variable. Therefore, it's going to write a null string.

Therefore, you need to put the contents of inputtext into this variable: PlayerInfo[playerid][xPassword]
Mmm? I don't understand, do you want fix it for me? Important me. Please.
Reply
#5

Bump! Pleasee, somebody help me
Reply
#6

[code]
format(PlayerInfo[playerid][xPassword], 64, "%s", inputtext);

case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{800000}Error","{686868}Type a password","Login","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteString(File,"Password",inputtext);
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_Close(File);
}
}
Reply
#7

PlayerInfo[playerid][xPassword] can only save the numbers as many posts said you must change
pawn Код:
INI_WriteString(File,"Password",PlayerInfo[playerid][xPassword]);
to

pawn Код:
INI_WriteString(File,"Password",inputtext);
also you're not using a hash... do u plan on stealing the passwords of other users maybe?
Reply
#8

Nevermind, i make new user system and it's work. Thank you all anyway
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)