27.10.2012, 19:39
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;
}