SA-MP Forums Archive
Passwords aren't saving upon registering/logging in. - 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: Passwords aren't saving upon registering/logging in. (/showthread.php?tid=380607)



Passwords aren't saving upon registering/logging in. - iLcke - 26.09.2012

Title ^

pawn Код:
if(dialogid == DIALOG_REGISTER)
{
if(response)
{
if(!strlen(inputtext))
{
format(dr1, sizeof(dr1), "Welcome to ---, %s.", plname);
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD , dr1, "This account isn't registered yet. If you wish to contiune, you must register by putting in a password.", "Register", "Leave");
return 1;
}
GetPlayerName(playerid, plname, sizeof(plname));
format(string, sizeof(string), "users/%s.ini", plname);
new File:hFile;
new passw = strval( inputtext );
hFile = fopen(string, io_append);
new var[32];//
format(var, 32, "pPass=%s\n", passw);fwrite(hFile, var);
format(var, 32, "pAdmin=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
format(var, 32, "pSex=%d\n",PlayerInfo[playerid][pSex]);fwrite(hFile, var);
format(var, 32, "pSupporter=%d\n",PlayerInfo[playerid][pSupporter]);fwrite(hFile, var);
format(var, 32, "pCash=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
format(var, 32, "pAge=%d\n",PlayerInfo[playerid][pAge]);fwrite(hFile, var);
format(var, 32, "pLevel=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
format(var, 32, "pTut=%d\n",PlayerInfo[playerid][pTut]);fwrite(hFile, var);
format(var, 32, "pRace=%d\n",PlayerInfo[playerid][pRace]);fwrite(hFile, var);
fclose(hFile);
gPlayerAccount[playerid] = 1;
AntiHack(playerid, 1500);
SendClientMessage(playerid, COLOR_YELLOW, "Registered, we'll now send you towards the tutorial.");
Tutorial(playerid);
OnPlayerLogin(playerid,inputtext);
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "You have left the server..");
Kick(playerid);
}
}
I seen something similar that a guy using ini was having the same problems, but im not sure.


Re: Passwords aren't saving upon registering/logging in. - Rimeau - 26.09.2012

Try this:

pawn Код:
if(dialogid == DIALOG_REGISTER)
{
    if(response)
    {
        if(!strlen(inputtext))
        {
            format(dr1, sizeof(dr1), "Welcome to ---, %s.", plname);
            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD , dr1, "This account isn't registered yet. If you wish to contiune, you must register by putting in a password.", "Register", "Leave");
            return 1;
        }
        GetPlayerName(playerid, plname, sizeof(plname));
        format(string, sizeof(string), "\users\%s.ini", plname);
        if(fexist(string))
        {
            new File:hFile = fopen(string, io_write); //Append is for adding something
            //new passw = strval( inputtext ); //strval returns an integer, password should be a string. Just use inputtext
            new var[32];//Make sure the password isnt longer than 23 characters
            format(var, 32, "pPass=%s\n", inputtext);fwrite(hFile, var);
            format(var, 32, "pAdmin=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
            format(var, 32, "pSex=%d\n",PlayerInfo[playerid][pSex]);fwrite(hFile, var);
            format(var, 32, "pSupporter=%d\n",PlayerInfo[playerid][pSupporter]);fwrite(hFile, var);
            format(var, 32, "pCash=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
            format(var, 32, "pAge=%d\n",PlayerInfo[playerid][pAge]);fwrite(hFile, var);
            format(var, 32, "pLevel=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
            format(var, 32, "pTut=%d\n",PlayerInfo[playerid][pTut]);fwrite(hFile, var);
            format(var, 32, "pRace=%d\n",PlayerInfo[playerid][pRace]);fwrite(hFile, var);
            fclose(hFile);
            gPlayerAccount[playerid] = 1;
            AntiHack(playerid, 1500);
            SendClientMessage(playerid, COLOR_YELLOW, "Registered, we'll now send you towards the tutorial.");
            Tutorial(playerid);
            OnPlayerLogin(playerid,inputtext);
        }
        else {} //Account does on exist
    }
    else
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "You have left the server..");
        Kick(playerid);
    }
}



Re: Passwords aren't saving upon registering/logging in. - iLcke - 26.09.2012

Now that doesn't work at all, won't even send me the welcome message.


Re: Passwords aren't saving upon registering/logging in. - Rimeau - 26.09.2012

I didn't change that part, see if your dialogid and response are correct


Re: Passwords aren't saving upon registering/logging in. - BrandyPenguin - 26.09.2012

File get created?