22.10.2016, 03:35
Okay so my password hashes and saves correctly into the database however once a player is registered and can play and they log off and log back online it prompts them that there Password is incorrect however i've tested multiple times and that is not the case.
LOGIN DIALOG:
REGISTER DIALOG:
Код:
public OnPlayerRegister(name[]) { if(cache_get_row_count() < 1) return print("[ERROR] OnPlayerRegister returned 'rows' as '0'."); new password[129], string[64], ip[16]; cache_get_field_content(0, "Pass", PlayerInfo[playerid][pPass], dbHandle, 129); print("[DEBUG onPlayerRegister main]"); new playerid = FindPlayer(name); if(playerid != -1) { print("[DEBUG onPlayerRegister is online ]"); SCM(playerid,COLOR_PLAGREEN,"Your account has been approved!"); new hashpass[129]; WP_Hash(hashpass, sizeof(hashpass), hashpass); format(query, sizeof(query), "INSERT INTO `users` (name, password, registered, origin, playerIP) VALUES ('%s', '%s', 0, 'None', '%s')", name, hashpass, ip); mysql_function_query(dbHandle, query, true, "OnPlayerCreateAccount", "d", playerid); format(PlayerInfo[playerid][pPass],129,"%s",hashpass); }
Код:
public OnPlayerCreateAccount(playerid) { PlayerInfo[playerid][pDatabaseID] = cache_insert_id(dbHandle); Dialog_Show(playerid, Secret, DIALOG_STYLE_INPUT, ""EMBED_WHITE"Welcome"EMBED_WHITE"", ""EMBED_WHITE"Enter a security question.", "Continue", "Quit"); return 1; }
Код:
Dialog:Login(playerid, response, listitem, inputtext[]) { cache_get_field_content(0, "password", PlayerInfo[playerid][pPass], dbHandle, 129); if(response) { if(isnull(inputtext)) { Dialog_Show(playerid, Login, DIALOG_STYLE_PASSWORD, ""EMBED_WHITE"Welcome"EMBED_WHITE"", loginMsg, "Login", "Cancel"); return 1; } new hashpass[129]; WP_Hash(hashpass, sizeof(hashpass), inputtext); if(!strcmp(hashpass, PlayerInfo[playerid][pPass])) { format(query, sizeof(query), "SELECT * FROM `users` WHERE `name` = '%s' AND `password` = '%s' LIMIT 0,1", GetName(playerid), hashpass); mysql_function_query(dbHandle, query, true, "LoginPlayer", "i", playerid); } else { Dialog_Show(playerid, Login, DIALOG_STYLE_PASSWORD, ""EMBED_WHITE"Welcome"EMBED_WHITE"", loginMsg, "Login", "Cancel"); } } else { Kick(playerid); } return 1; }
Код:
Dialog:Register(playerid, response, listitem, inputtext[]) { if (response) { if(isnull(inputtext)) { Dialog_Show(playerid, Register, DIALOG_STYLE_INPUT, ""EMBED_WHITE"Welcome"EMBED_WHITE"", msg, "Register", "Quit"); return 1; } if(strlen(inputtext) < 6) { Dialog_Show(playerid, Register, DIALOG_STYLE_INPUT, ""EMBED_WHITE"Welcome"EMBED_WHITE"", msg, "Register", "Quit"); return 1; } SetPVarInt(playerid, "Approve", 0); SetPVarString(playerid, "TempPassword", inputtext); SetPVarInt(playerid, "TutQuestAmount", 0); SetIntVar(playerid, "RegisterPart", 1); return CallRemoteFunction("TutorialAnswers","i",playerid); } else { Kick(playerid); } return 1; }