Reading a string from file with djSon - 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: Reading a string from file with djSon (
/showthread.php?tid=326262)
Reading a string from file with djSon -
sim_sima - 16.03.2012
Okay, recently I made another topic about this, but I was unssure about what caused the issue.
Now I have found out where the problem is, but dont know how to solve it.
I am trying to make a login/register system using djSon to save data and Whirlpool to hash passwords.
The register part works fine, the password is hashed and saved, but the problem lays in the login part. I simply can't get djSon to return the string from the password field.
My code currently looks like this in the login dialog:
pawn Код:
if(dialogid == 2)
{
if(!response)
{
StopAudioStreamForPlayer(playerid);
SendClientMessage(playerid, COLOR_SYSTEMRED, "( ! ) You must log in to play on this server. Please come again soon");
Kick(playerid);
gPlayerLogged[playerid] = 0;
}
new hashed_password[129];
WP_Hash(hashed_password, sizeof(hashed_password), inputtext);
if(strcmp(hashed_password, dj(file, "Password"), false))
{
SendClientMessage(playerid, COLOR_GREEN, "( ! ) You have successfully Logged In!");
GivePlayerMoney(playerid, djInt(file, "Money"));
PlayerInfo[playerid][pBanned] = djInt(file, "Banned");
gPlayerLogged[playerid] = 1;
OnceLogged[playerid] = 1;
}
else
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "{FFFF00}Hopes Hills RPG Account", "{AF0000}Incorrect Password!\n{FFFFFF}Enter your Password", "Login", "Quit");
}
The problem is in this line:
pawn Код:
if(strcmp(hashed_password, dj(file, "Password"), false))
As I said, concluded after some debugging, the problem is returning the string from the password field.
Hope someone can help. Thanks.
Re: Reading a string from file with djSon -
sim_sima - 17.03.2012
No one?