[Help]MySQL changepass cmd
#1

I tried to make a /changepass cmd around 1 h, but i don't understand why is not working. MySQL version is r41.
The old password is doesn't change, it stay same. So when i change the password the querry is working but is doesn't change the password
Код HTML:
CMD:changepass(playerid, params[])
{
	new newpass[65], query[221], string[64];
	if(Player[playerid][IsLoggedIn] == false) return 0;
	if(sscanf(params, "s[65]", newpass)) return SendClientMessage(playerid, -1, "Use: /changepass [new password]");
	
	format(string, sizeof string, "You chnage your password to %s", newpass);
	SendClientMessage(playerid, -1, string);
	
	for (new i = 0; i < 16; i++) Player[playerid][Salt][i] = random(94) + 33;
	SHA256_PassHash(newpass, Player[playerid][Salt], Player[playerid][Password], 65);
	
	mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `password`= %s,`salt`= %e WHERE `id` = %d LIMIT 1", Player[playerid][Password], Player[playerid][Salt], Player[playerid][ID]);
	mysql_tquery(g_SQL, query);
	print(query);
	
	return 1;
}
If you need something else, tell me.
Reply
#2

Error in syntax because strings need apostrophes around them like '%e' or '%s'.

By the way, you don't need sscanf for 1 string parameter. Use isnull + params.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Error in syntax because strings need apostrophes around them like '%e' or '%s'.

By the way, you don't need sscanf for 1 string parameter. Use isnull + params.
Thank you, such a noob , i din't think about apostrophes.
I use sscanf because i'm to familiar to it, i never use isnull.Thank you again.
Reply
#4

It is quite simpler:
pawn Код:
if(sscanf(params, "s[65]", newpass)) return SendClientMessage(playerid, -1, "Use: /changepass [new password]");
becomes:
pawn Код:
if(isnull(params)) return SendClientMessage(playerid, -1, "Use: /changepass [new password]");
and you replace newpass with params.

You're welcome anyway.
Reply
#5

For security reasons it's better to ask and verify the old pass as well. Especially if you have auto-login. And in that case you do need sscanf.
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
For security reasons it's better to ask and verify the old pass as well. Especially if you have auto-login. And in that case you do need sscanf.
Yeah, i know, but i try to make something basic and expand&develop after. I didn't touch scripting for a while and forget things and i want to regain them back , like the apostrophe on strings in query lol. But thanks for answer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)