[Help] Password change. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] Password change. (
/showthread.php?tid=219209)
[Help] Password change. -
Rocketeer - 31.01.2011
Hey guys, i use mysql, i want to make a command that allows players to change their own passwords, Lethal helped me out by giving me this code.
PHP код:
CMD:changepass(playerid, params[])
{
new
EscPass[40],
Query[128],
iStr[55];
if(isnull(params)) return SendClientMessage(playerid, -1, ""#CRED"Usage: "#CORANGE"/ChangePass < New Password >");
mysql_real_escape_string(params, EscPass);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `password` = md5('%s') WHERE `user` = '%s'", EscPass, pName(playerid));
mysql_query(Query);
format(iStr, sizeof(iStr), "You've changed your password to: "#CBLUE"%s", params);
SendClientMessage(playerid, -1, iStr);
return 1;
}
At the end it tells me that i've changed my password to: BlaBla.
In reality tho, it does not change it in database, am i missing some code? Please help, thanks.
Re: [Help] Password change. -
David5290 - 31.01.2011
I believe you need a place for it to save, an accountpath
pawn Код:
if(sscanf(params, "ss", oldpass, newpass)) SendUsage(playerid, "USAGE: /changepass [old password] [new password]");
else
{
new accountpath[64]; format(accountpath, sizeof(accountpath), "%s", AccountPath(playerid));
new buf[129];
WP_Hash(buf, sizeof(buf), oldpass);
if(strcmp(dini_Get(accountpath, "password"), oldpass, true) == 0)
{
WP_Hash(buf, sizeof(buf), newpass);
dini_Set(accountpath, "password", newpass);
SendClientMessage(playerid, COLOR_GREEN, "SUCCESS: You have changed your password.");
}
Re: [Help] Password change. -
Rocketeer - 31.01.2011
Solved!