Help with changepass command. - 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: Help with changepass command. (
/showthread.php?tid=388170)
Help with changepass command. -
andrew2695 - 27.10.2012
Hi, I have made this changepass command but when I use it in-game I always get wrong password. There is something wrong with the hashing.
pawn Код:
CMD:changepass(playerid, params[])
{
new str[128], pass[129], params2[129];
if(!Info[playerid][Logged]) return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in.");
if(sscanf(params, "s[129]s[129]", params, params2)) return SendClientMessage(playerid, COLOR_RED, "Usage: /changepass (old password) (new password)");
if(strlen(params2) < 3 || strlen(params2) > 24) return SendClientMessage(playerid, COLOR_RED, "Incorrect Password Length. Please choose a password between 4 and 20 characters.");
WP_Hash(pass, sizeof(pass), params);
if(!strcmp(pass, params))
{
WP_Hash(pass, sizeof(pass), params2);
new INI:File = INI_Open(UserPath(playerid ));
INI_SetTag(File, "Player Data");
INI_WriteString(File, "Password", pass);
INI_Close(File);
format(str, sizeof(str), "You change your password to '%s'", params2);
SendClientMessage(playerid, COLOR_GREEN, str);
}
else return SendClientMessage(playerid, COLOR_RED, "You have entered an incorrect password. Please try again.");
return 1;
}
Re: Help with changepass command. -
CoaPsyFactor - 27.10.2012
if(!strcmp(pass, params))

You compare hash with inserted password

This two are not same
Re: Help with changepass command. -
andrew2695 - 28.10.2012
How could I fix it?
Re: Help with changepass command. -
-=Dar[K]Lord=- - 28.10.2012
Do you Have Anyvariable for Password such as pInfo[playerid][Pass] and all... ?
if u have then use this one
pawn Код:
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(!strcmp(hashpass,pInfo[playerid][Pass]))
{
///Code