CMD:changepass(playerid, params[]) { new file[128]; format(file, 128, USER_FILE, GetPName(playerid)); new OldPass, NewPass; if(sscanf(params, "ss", OldPass, NewPass)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changepass (password) (new password)"); if(OldPass == NewPass) return SendClientMessage(playerid, COLOR_RED, "ERROR: You typed same password"); dini_IntSet(file, "Password", udb_hash(NewPass)); SendClientMessage(playerid, COLOR_RED, "You have changed your password."); return 1; }
new OldPass, NewPass;
both of them ?
cause it gave me that error 033: array must be indexed (variable "OldPass") |
Yes, both of them as they are indeed strings. You compare strings using the function strcmp, so change you're same password check to use that.
Also, you should make sure the old pass matches the actual old password before setting a new one. |
if(OldPass == NewPass) return SendClientMessage(playerid, COLOR_RED, "ERROR: You typed same password");
CMD:changepass(playerid, params[]) { new file[128]; format(file, 128, USER_FILE, GetPName(playerid)); new OldPass[50], NewPass[50]; if(sscanf(params, "ss", OldPass, NewPass)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changepass (password) (new password)"); if(OldPass == NewPass) return SendClientMessage(playerid, COLOR_RED, "ERROR: You typed same password"); dini_IntSet(file, "Password", udb_hash(NewPass)); SendClientMessage(playerid, COLOR_RED, "You have changed your password."); return 1; }
CMD:changepass(playerid, params[])
{
new file[128];
format(file, 128, USER_FILE, GetPName(playerid));
new OldPass[80], NewPass[80];
if(sscanf(params, "ss", OldPass, NewPass)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changepass (password) (new password)");
if(udb_hash(OldPass) != udb_hash(dini_Int(file, "Password"))) return SendClientMessage(playerid, COLOR_RED, "ERROR: Your old password does not match!");
if(udb_hash(OldPass) == udb_hash(NewPass)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You typed same password");
dini_IntSet(file, "Password", udb_hash(NewPass));
SendClientMessage(playerid, COLOR_RED, "You have changed your password.");
return 1;
}
if(udb_hash(OldPass) != udb_hash(dini_Int(file, "Password"))) return SendClientMessage(playerid, COLOR_RED, "ERROR: Your old password does not match!"); |