SA-MP Forums Archive
First alphabet of the password only - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: First alphabet of the password only (/showthread.php?tid=101992)



First alphabet of the password only - Peter_Corneile - 13.10.2009

Hello,

I have a problem with my register system.

If a person registers with the password "Happy" in scriptfiles his password is saved as "H" , only the first alphabet .... I dont know why ... Please look at the register command below


pawn Код:
new playername[MAX_PLAYER_NAME];
            new string[500];
            PlayerInfo[playerid][pPassword] = inputtext[playerid];
            GetPlayerName(playerid, playername, sizeof(playername));
            format(string, sizeof(string), "\\Accounts\\%s.ini", playername);
            new File: file = fopen(string, io_read);
            if (file)
            {
                new s[128],pName[24];
                GetPlayerName(playerid, pName, 24);
            format(s,sizeof(s),"Welcome, %s!\n\nThat name is allready used",pName);
                ShowPlayerDialog(playerid,60,1,"Register your account",s,"Register"," ");
                fclose(file);
                Kick(playerid);
                return 1;
            }
            new File:hFile;
            hFile = fopen(string, io_append);
            new var[32];
        format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var);
        format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
        format(var, 32, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
        PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
        format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
        format(var, 32, "Admin=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
            fclose(hFile);
            SendClientMessage(playerid, Green, "[Server]: Succesfully Registered!");
            OnPlayerLogin(playerid,inputtext);
            TutorialTime[playerid] = 1;

Thanks for helping


Re: First alphabet of the password only - yom - 13.10.2009

Not sure but i think you have a warning on this line:

PlayerInfo[playerid][pPassword] = inputtext[playerid];

In the version of PAWN that SA-MP uses, you can't copy an array into another by using "=". Use another way, such as format.

When compiling, this line basically transform into:

PlayerInfo[playerid][pPassword][0] = inputtext[playerid][0]; hence why you have only the first letter saved in the file.


Re: First alphabet of the password only - woot - 13.10.2009

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



Re: First alphabet of the password only - Peter_Corneile - 13.10.2009

Quote:
Originally Posted by 0rb
Not sure but i think you have a warning on this line:

PlayerInfo[playerid][pPassword] = inputtext[playerid];

In the version of PAWN that SA-MP uses, you can't copy an array into another by using "=". Use another way, such as format.

When compiling, this line basically transform into:

PlayerInfo[playerid][pPassword][0] = inputtext[playerid][0]; hence why you have only the first letter saved in the file.
Alright let me test


Re: First alphabet of the password only - Peter_Corneile - 13.10.2009

I tried to change that
pawn Код:
=
to
pawn Код:
==
but now it gives me a warning (previously it didnt)


Re: First alphabet of the password only - dice7 - 13.10.2009

Quote:
Originally Posted by //exora
pawn Код:
format(PlayerInfo[playerid][pPassword], 64, "%s", inputtext[playerid]);



Re: First alphabet of the password only - Peter_Corneile - 13.10.2009

Looks like it is fixed .. THanks ... I will inform you guys if i find a bug ... Thanks a lot