My changepass command is not working. Would need some help please.
#1

Hi, im trying to fix my changepass command but dont get what is wrong with it. Some help would be really appreciated.

pawn Код:
CMD:changepass(playerid, params[])
{
    new pass[129], newpass[129], hashpass[129];
    if(!Info[playerid][Logged]) return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in.");
    if(sscanf(params, "s[129]s[129]", params, newpass)) return SendClientMessage(playerid, COLOR_RED, "Usage: /changepass [Old Password] [New Password]");
    if(strlen(newpass) < 3 || strlen(newpass) > 24) return SendClientMessage(playerid, COLOR_RED, "Incorrect Password Length. Please choose a password between 4 and 20 characters.");
    WP_Hash(hashpass,sizeof(hashpass), params);
    if(!strcmp(hashpass, Info[playerid][Password]))
    {
        WP_Hash(pass, sizeof(pass), newpass);
        new INI:File = INI_Open(UserPath(playerid ));
        INI_SetTag(File, "Player Data");
        INI_WriteString(File, "Password", pass);
        INI_Close(File);
        SendClientMessageFormatted(playerid, COLOR_RED, "You have sucessfuly changed your password to '%s'.", newpass);
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You have entered an incorrect password. Please try again.");
    }
    return 1;
}
Reply
#2

It should work.
pawn Код:
CMD:changepass(playerid, params[])
{
    new
        oldpass[24],
        newpass[24],
        hashpass[129]
    ;
    if(!Info[playerid][Logged]) return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in.");
    if(sscanf(params, "s[24]s[24]", oldpass, newpass)) return SendClientMessage(playerid, COLOR_RED, "Usage: /changepass [Old Password] [New Password]");
    if(strlen(newpass) < 3 || strlen(newpass) > 24) return SendClientMessage(playerid, COLOR_RED, "Incorrect Password Length. Please choose a password between 4 and 20 characters.");
    WP_Hash(hashpass,sizeof(hashpass), oldpass);
    if(!strcmp(hashpass, Info[playerid][Password]))
    {
        WP_Hash(hashpass, sizeof(hashpass), newpass);
        new INI:File = INI_Open(UserPath(playerid ));
        INI_SetTag(File, "Player Data");
        INI_WriteString(File, "Password", hashpass);
        INI_Close(File);
        SendClientMessageFormatted(playerid, COLOR_RED, "You have sucessfuly changed your password to '%s'.", newpass);
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You have entered an incorrect password. Please try again.");
    }
    return 1;
}
Reply
#3

Thank you for trying Dawne but it's not working. Does anyone know whats wrong with it?
Reply
#4

Try:

pawn Код:
CMD:changepass(playerid, params[])
{
    new pass[24], newpass[24], hashpass[24];
    if(!Info[playerid][Logged]) return SendClientMessage(playerid, COLOR_RED, "Error: You are not logged in.");
    if(sscanf(params, "s[24]s[24]", params, newpass)) return SendClientMessage(playerid, COLOR_RED, "Usage: /changepass [Old Password] [New Password]");
    if(strlen(newpass) < 3 || strlen(newpass) > 24) return SendClientMessage(playerid, COLOR_RED, "Incorrect Password Length. Please choose a password between 4 and 20 characters.");
    WP_Hash(hashpass,sizeof(hashpass), params);
    if(strcmp(hashpass, Info[playerid][Password], true) == 0)
    {
        WP_Hash(pass, sizeof(pass), newpass);
        new INI:File = INI_Open(UserPath(playerid ));
        INI_SetTag(File, "Player Data");
        INI_WriteString(File, "Password", pass);
        INI_Close(File);
        SendClientMessageFormatted(playerid, COLOR_RED, "You have sucessfuly changed your password to '%s'.", newpass);
    }
    else SendClientMessage(playerid, COLOR_RED, "You have entered an incorrect password. Please try again.");
    return 1;
}
Reply
#5

No, It's always return You have sucessfuly changed your password and it delete the password. I'll start to think that it's impossible to change someone password lol.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)