SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 06/03/2013, 12:17 AM   #1
ZmaXy
Big Clucker
 
ZmaXy's Avatar
 
Join Date: Oct 2010
Location: Jamaica
Posts: 192
Reputation: 1
Default Password isn't saved [y_ini]

Password isn't saved


pawn Code:
enum xInfo
{
    xPassword[64],
    xMoney,
    xAdmin
}
new PlayerInfo[MAX_PLAYERS][xInfo];

pawn Code:
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 Code:
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 Code:
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 Code:
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
ZmaXy is offline   Reply With Quote
Old 06/03/2013, 12:23 AM   #2
Glad2BeHere
Gangsta
 
Glad2BeHere's Avatar
 
Join Date: Oct 2012
Posts: 759
Reputation: 136
Default Re: Password isn't saved [y_ini]

pawn 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");
                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);
            }
        }
Glad2BeHere is offline   Reply With Quote
Old 06/03/2013, 12:26 AM   #3
Scenario
Godfather
 
Scenario's Avatar
 
Join Date: Feb 2010
Location: Heaven
Posts: 7,809
Reputation: 701
Default Re: Password isn't saved [y_ini]

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]
Scenario is offline   Reply With Quote
Old 06/03/2013, 04:18 AM   #4
ZmaXy
Big Clucker
 
ZmaXy's Avatar
 
Join Date: Oct 2010
Location: Jamaica
Posts: 192
Reputation: 1
Default Re: Password isn't saved [y_ini]

@Glad2BeHere, No, it doesn't work.

Quote:
Originally Posted by RealCop228 View Post
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.
ZmaXy is offline   Reply With Quote
Old 06/03/2013, 12:21 PM   #5
ZmaXy
Big Clucker
 
ZmaXy's Avatar
 
Join Date: Oct 2010
Location: Jamaica
Posts: 192
Reputation: 1
Default Re: Password isn't saved [y_ini]

Bump! Pleasee, somebody help me
ZmaXy is offline   Reply With Quote
Old 06/03/2013, 01:36 PM   #6
kristijan250
Little Clucker
 
Join Date: Sep 2012
Posts: 19
Reputation: 0
Default Re: Password isn't saved [y_ini]

[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);
}
}
kristijan250 is offline   Reply With Quote
Old 06/03/2013, 01:51 PM   #7
L.Hudson
Huge Clucker
 
L.Hudson's Avatar
 
Join Date: Jul 2012
Location: Fairy Tail, Fiore
Posts: 226
Reputation: 16
Default Re: Password isn't saved [y_ini]

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

to

pawn Code:
INI_WriteString(File,"Password",inputtext);

also you're not using a hash... do u plan on stealing the passwords of other users maybe?

Last edited by L.Hudson; 06/03/2013 at 02:56 PM.
L.Hudson is offline   Reply With Quote
Old 06/03/2013, 03:58 PM   #8
ZmaXy
Big Clucker
 
ZmaXy's Avatar
 
Join Date: Oct 2010
Location: Jamaica
Posts: 192
Reputation: 1
Default Re: Password isn't saved [y_ini]

Nevermind, i make new user system and it's work. Thank you all anyway
ZmaXy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Y_INI] Can login with any password O.o Jarnu Scripting Help 15 28/09/2012 10:51 AM
Y_ini not saving Password. Benzke Scripting Help 1 11/09/2012 11:36 AM
[+REP] Y_INI Password help Joshb93 Scripting Help 2 01/04/2012 09:57 PM
Y_INI Password problem. ryansheilds Scripting Help 3 15/02/2012 03:24 AM
y_ini. Cannot load Password. Konstantinos Scripting Help 2 16/01/2012 03:52 PM


All times are GMT. The time now is 04:00 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.