SA-MP Forums Archive
Change Pass - 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: Change Pass (/showthread.php?tid=471718)



Change Pass - AnonScripter - 24.10.2013

why this sends me that my old pass is incorrect even if it is correct ?

pawn Код:
CMD:changepass(playerid,params[])
{
    new string[128], newpass;
    new oldpass = PlayerInfo[playerid][pPass];
    if(sscanf(params, "ss", oldpass, newpass)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFF00}[Usage:]: {FFFFFF}/changepass [old password] [new password]");
    if(oldpass != PlayerInfo[playerid][pPass]) return SendClientMessage(playerid,COLOR_RED,"Error: Your old password is incorrect, please try again.");
    if(newpass == PlayerInfo[playerid][pPass]) return SendClientMessage(playerid,COLOR_RED,"Error: Your new password is the current password.");
    else
    {
        PlayerInfo[playerid][pPass] = newpass;
        format(string, sizeof(string), "Your password is successfully changed to: %s", newpass);
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    return 1;
}



Re: Change Pass - Patrick - 24.10.2013

Just a question, what saving system do you use?


Re: Change Pass - AnonScripter - 24.10.2013

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
Just a question, what saving system do you use?
i was about to edit the topic to add this note, but you replied quickly
anyway it's Y_INI


Re: Change Pass - DanishHaq - 24.10.2013

pawn Код:
CMD:changepass(playerid,params[])
{
    new string[128], newpass[50], oldpass[50];
    if(sscanf(params, "s[50]s[50]", oldpass, newpass)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFF00}[Usage:]: {FFFFFF}/changepass [old password] [new password]");
    if(oldpass != PlayerInfo[playerid][pPass]) return SendClientMessage(playerid,COLOR_RED,"Error: Your old password is incorrect, please try again.");
    if(newpass == PlayerInfo[playerid][pPass]) return SendClientMessage(playerid,COLOR_RED,"Error: Your new password is the current password.");
    else
    {
        PlayerInfo[playerid][pPass] = newpass;
        format(string, sizeof(string), "Your password is successfully changed to: %s", newpass);
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    return 1;
}
Try that.


Re: Change Pass - AnonScripter - 24.10.2013

Код:
(3736) : error 033: array must be indexed (variable "oldpass")
(3737) : error 033: array must be indexed (variable "newpass")
(3740) : error 006: must be assigned to an array
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.



Re: Change Pass - rickisme - 24.10.2013

Here

pawn Код:
CMD:changepass(playerid,params[])
{
    new string[128],
        oldpass[32],
        newpass[32];
       
    if(sscanf(params, "s[32]s[32]", oldpass, newpass)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFF00}[Usage:]: {FFFFFF}/changepass [old password] [new password]");
    if(strcmp(PlayerInfo[playerid][pPass], oldpass, false) == 0)
    {
        if(strcmp(PlayerInfo[playerid][pPass], newpass, false) == 0) return SendClientMessage(playerid,COLOR_RED,"Error: Your new password is the current password.");
        format(PlayerInfo[playerid][pPass], 32, newpass);
        format(string, sizeof(string), "Your password is successfully changed to: %s", newpass);
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    else
    {
        SendClientMessage(playerid,COLOR_RED,"Error: Your old password is incorrect, please try again.");
    }
    return 1;
}



Re: Change Pass - AnonScripter - 24.10.2013

same problem, sends the same message (old pass is incorrect)


Re: Change Pass - GiamPy. - 24.10.2013

Can you show us the registering part of the account?


Re: Change Pass - Pottus - 24.10.2013

Are your passwords hashed ?


Re: Change Pass - GiamPy. - 24.10.2013

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Are your passwords hashed ?
That's exactly what I wanted to know, lol.

Quote:
Originally Posted by AnonScripter
Посмотреть сообщение
Register system is: https://sampforum.blast.hk/showthread.php?tid=273088

all default, i didn't change anything of it.
Try:

pawn Код:
CMD:changepass(playerid,params[])
{
    new string[128],
        oldpass[32],
        newpass[32];
       
    if(sscanf(params, "s[32]s[32]", oldpass, newpass)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFF00}[Usage:]: {FFFFFF}/changepass [old password] [new password]");
    if(!strcmp(udb_hash(oldpass), udb_hash(newpass)))
    {
        if(!strcmp(PlayerInfo[playerid][pPass], udb_hash(newpass))) return SendClientMessage(playerid,COLOR_RED,"Error: Your new password is the current password.");
        format(PlayerInfo[playerid][pPass], 32, newpass);
        format(string, sizeof(string), "Your password is successfully changed to: %s", newpass);
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    else
    {
        SendClientMessage(playerid,COLOR_RED,"Error: Your old password is incorrect, please try again.");
    }
    return 1;
}
I highly suggest you to use another hashing system though, like Whirlpool.