SA-MP Forums Archive
changepass mysql [+REP] - 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: changepass mysql [+REP] (/showthread.php?tid=564280)



changepass mysql [+REP] - simo0000 - 20.02.2015

hi guys i make a cmd for player change his password it change in mysql database but the proble is
when i change my pass it doesn't check if the old pass if correct plz help

pawn Код:
CMD:changepass(playerid,params[])
{
    new oldpass[128];
    new query[313], name[24], WPhash[145], escape[145];
    if(sscanf(params, "s[128]s[128]", oldpass, WPhash)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /changepass (Old Password) (New Password)");
    //else if(oldpass == wrongpassword) return SendClientMessage(playerid, COLOR_ERROR, "Error: Wrong 'Old password'");
    {
        GetPlayerName(playerid,name,24);
        mysql_real_escape_string(oldpass, escape);
        WP_Hash(WPhash, sizeof(WPhash), escape);
        mysql_format(mysql, query, sizeof(query), "UPDATE `Players` SET `Password` = '%s' WHERE `Username` = '%s'", WPhash, name);
        mysql_query(mysql, query,"", "");
        SendClientMessage(playerid, COLOR_GREEN, "Password Changed!");
    }
    return 1;
}
sorry for my bad english

best regards


Re: changepass mysql [+REP] - Sledgehammer - 20.02.2015

The variable "oldpass" is returning "null".


Re : Re: changepass mysql [+REP] - simo0000 - 20.02.2015

Quote:
Originally Posted by Sledgehammer
Посмотреть сообщение
The variable "oldpass" is returning "null".
plz explain more


Re: changepass mysql [+REP] - Sledgehammer - 20.02.2015

What enum do you store your current/ oldpassword in? Because the command isn't going to store that data for you.

Also, This check:
Код:
//else if(oldpass == wrongpassword)
Will not work at all, Use strcmp since you are comparing strings.


Re: changepass mysql [+REP] - JeaSon - 20.02.2015

you need to select that table and column then get data from it and load it into oldpass in cmd


Re : changepass mysql [+REP] - simo0000 - 20.02.2015

i remove oldpass variable i don't need it anymore xD [SOLVED]
pawn Код:
CMD:changepass(playerid,params[])
{
    new query[313], name[24], WPhash[145], escape[145];
    if(sscanf(params, "s[128]", WPhash)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /changepass (New Password)");
    {
        GetPlayerName(playerid,name,24);
        mysql_real_escape_string(oldpass, escape);
        WP_Hash(WPhash, sizeof(WPhash), escape);
        mysql_format(mysql, query, sizeof(query), "UPDATE `Players` SET `Password` = '%s' WHERE `Username` = '%s'", WPhash, name);
        mysql_query(mysql, query,"", "");
        SendClientMessage(playerid, COLOR_GREEN, "Password Changed!");
    }
    return 1;
}
thanks for everyone