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;
}
if(sscanf(params, "s[24]s[24]", oldpass, newpass))
if(sscanf(params, "ss", oldpass, newpass))
new name[MAX_PLAYER_NAME], file[128], tmp, oldpass, newpass;
new name[MAX_PLAYER_NAME], file[128], tmp, oldpass[24], newpass[24];
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; }
COMMAND:changepass(playerid, params[]) { new name[ MAX_PLAYER_NAME ], file[ 128 ], tmp, oldpass[ 24 ], newpass[ 24 ]; GetPlayerName( playerid, name, MAX_PLAYER_NAME ); format( file, sizeof(file), UserFile, name ); if( sscanf(params, "s[24]s[24]", oldpass, newpass ) ) return SendClientMessage( playerid, COLOR_SYSTEMRED, "USAGE: /changepass <oldpass> <newpass>" ); tmp = djInt( file, "Password" ); if( tmp == udb_hash( 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; }
First of all, specific to your inquiry about sscanf, you should specify the length of each string by encapsulating the maximum size in square brackets. For example, if the maximum length of each string is 24 characters, you would use
Код:
if(sscanf(params, "s[24]s[24]", oldpass, newpass)) Код:
if(sscanf(params, "ss", oldpass, newpass)) Код:
new name[MAX_PLAYER_NAME], file[128], tmp, oldpass, newpass; Код:
new name[MAX_PLAYER_NAME], file[128], tmp, oldpass[24], newpass[24]; In conclusion, changing Код:
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; } Код:
COMMAND:changepass(playerid, params[]) { new name[ MAX_PLAYER_NAME ], file[ 128 ], tmp, oldpass[ 24 ], newpass[ 24 ]; GetPlayerName( playerid, name, MAX_PLAYER_NAME ); format( file, sizeof(file), UserFile, name ); if( sscanf(params, "s[24]s[24]", oldpass, newpass ) ) return SendClientMessage( playerid, COLOR_SYSTEMRED, "USAGE: /changepass <oldpass> <newpass>" ); tmp = djInt( file, "Password" ); if( udb_hash( tmp ) == udb_hash( 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; } |
if( udb_hash( tmp ) == udb_hash( oldpass ) )
if( tmp == udb_hash( oldpass ) )
I had just edited it, I didn't notice it first but you are comparing a hashed version of the hashed password ( a hashed-hash
![]() Код:
if( udb_hash( tmp ) == udb_hash( oldpass ) ) Код:
if( tmp == udb_hash( oldpass ) ) |
if(newpass < 5 || newpass > 15) return SendClientMessage(playerid, COLOR_SYSTEMRED, "( ! ) Password must be between 5-15 characters");
Take an example from your original code - how did you write the login system?
And don't use udb_encode, it's very insecure, that's what things like whirlpool exist for. |
if(strlen(inputtext) > 15 || strlen(inputtext) < 5)
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFF00}Hopes Hills RPG Account", "{AF0000}Password must be between 5-15 characters\n{FFFFFF}Enter a Password", "Login", "Quit");
}
if(strlen(newpass ) < 5 || strlen(newpass ) > 15) return SendClientMessage(playerid, COLOR_SYSTEMRED, "( ! ) Password must be between 5-15 characters");