20.10.2016, 23:05
Alright basically when you join you get a temp password, if you get accepted that password gets used to create a player account, if not it removes it, that works fine, however once the player gets accepted and relogs and they enter their password it's saying it is incorrect, I'm really stumped and cannot find the problem.
My login dialog,
blah blah, then if we approve the player, and it calls the OnPlayerRegister function.
Код:
Dialog:Register(playerid, response, listitem, inputtext[]) { if (response) { if(isnull(inputtext)) { //Dialog here return 1; } if(strlen(inputtext) < 6) { //Dialog here 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 } return 1; }
Код:
Dialog:Login(playerid, response, listitem, inputtext[]) { if (response) { if(isnull(inputtext)) { //DIALOG CODE return 1; } new pass[129]; WP_Hash(pass, sizeof(pass), inputtext); format(query, sizeof(query), "SELECT * FROM `users` WHERE `name` = '%s' AND `password` = '%s' LIMIT 0,1", GetName(playerid), pass); mysql_function_query(dbHandle, query, true, "LoginPlayer", "i", playerid); } else { //Kick } return 1; }
Код:
public TutorialAnswers(playerid) { new string[128], playersip[32]; if(GetPVarInt(playerid, "TutQuestAmount") >= 10) { GetPlayerIp(playerid,playersip,sizeof(playersip)); DeletePVar(playerid,"AppSetup"), DeletePVar(playerid,"TutQuestAmount"); new stxt[65]; GetPVarString(playerid,"TempPassword",stxt,65); SHA256_PassHash(stxt, HASH_KEY, stxt, 65); DeletePVar(playerid,"TempPassword"); }
Код:
format(query, sizeof(query), "SELECT `Pass` FROM `applications` WHERE `Name`='%s'", name); mysql_function_query(dbHandle, query, true, "OnPlayerRegister", "s", name);
Код:
public OnPlayerRegister(name[]) { if(cache_get_row_count() < 1) return print("[ERROR] OnPlayerRegister returned 'rows' as '0'."); new password[65], string[64], ip[16]; cache_get_field_content(0, "Pass", password); new playerid = FindPlayer(name); if(playerid != -1) { // if player is online CreatePlayerAccount(playerid, password); } else { //else code } return 1; }
Код:
stock CreatePlayerAccount(playerid, password[]) { new ip[16], pass[129]; WP_Hash(pass, sizeof(pass), password); GetPlayerIp(playerid, ip, sizeof(ip)); format(query, sizeof(query), "INSERT INTO `users` (name, password, registered, origin, playerIP) VALUES ('%s', '%s', 0, 'None', '%s')", GetName(playerid), pass, ip); mysql_function_query(dbHandle, query, true, "OnPlayerCreateAccount", "d", playerid); return 1; }