30.06.2011, 11:55
Hello guys.
I'm making a /changepass <oldpass> <newpass> command for my user system.
I am using djson for data saving and sscanf with zcmd for multi parameter commands.
I dont have much experience with sscanf.
I did like this:
Note: I'm using dudb to hash the password (udb_hash())
Hope you can help me. Thank you.
I'm making a /changepass <oldpass> <newpass> command for my user system.
I am using djson for data saving and sscanf with zcmd for multi parameter commands.
I dont have much experience with sscanf.
I did like this:
pawn Код:
COMMAND:changepass(playerid, params[])
{
new name[MAX_PLAYER_NAME], file[128], tmp, oldpass, newpass;
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), UserFile, name);
if(sscanf(params, "ss", oldpass, newpass)) return SendClientMessage(playerid, COLOR_SYSTEMRED, "USAGE: /changepass <oldpass> <newpass>");
tmp = djInt(file, "Password");
if(udb_hash(tmp) == oldpass)
{
djSetInt(file, "Password", udb_hash(newpass));
SendClientMessage(playerid, COLOR_GREEN, "( ! ) Password change successful");
}
else SendClientMessage(playerid, COLOR_SYSTEMRED, "( ! ) The old password you entered is incorrect");
return 1;
}
Hope you can help me. Thank you.