20.09.2016, 12:25
So I have a command I've just created where you can change a users password while they're offline. Below is my code where I do that. When I execute the code in-game and go log into the accounts password I changed, it still doesn't change the password at all, it just keeps the same password and won't let me log in.
Код:
CMD:offchangepass(playerid, params[]) { new query_1[400], name[MAX_PLAYER_NAME], newpassword[20]; if(sscanf(params, "s[24]s[20]", name, newpassword)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /offchangepass [name] [new password]"); if(isnull(newpassword)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You must enter a new password in."); new len = strlen(newpassword); if(len > MAX_PASSWORD_LENGTH || len < MIN_PASSWORD_LENGTH) { new string[144]; format(string, sizeof (string), "ERROR: Invalid password length, must be between %i - %i characters.", MIN_PASSWORD_LENGTH, MAX_PASSWORD_LENGTH); return SendClientMessage(playerid, COLOR_RED, string); } strcat(query_1, "SELECT `"#USER_PASSWORD"`,"); strcat(query_1, "`"#USER_SALT"`"); strcat(query_1, " FROM `"#TABLE_USERS"`"); strcat_format(query_1, sizeof(query_1), " WHERE `"#USER_NAME"` = '%q' COLLATE NOCASE LIMIT 1", name); new DBResult:result = db_query(sabdm_database, query_1); if(db_num_rows(result)) { new query[300], string[144]; SHA256_PassHash(newpassword, USER_SALT, USER_PASSWORD, 65); strcat(query, "UPDATE `"#TABLE_USERS"` SET "); strcat_format(query, sizeof(query), "`"#USER_PASSWORD"` = '%q'", newpassword); strcat_format(query, sizeof(query), " WHERE `"#USER_NAME"` = '%q'", name); db_query(sabdm_database, query); format(string, sizeof(string), "You successfully changed %s's password.", name); SendClientMessage(playerid, COLOR_YELLOW_GREEN, string); } else { SendClientMessage(playerid, COLOR_RED, "[ERROR]: No user(s) were found using your query."); } db_free_result(result); return 1; }