04.08.2015, 15:09
So, When a player registers it shows the dialog twice and the first time it says the account isn't registered but when he see's the second one and clicks it says this account already exists.
I want it show the register dialog then the login dialog afterwards but it continues to show the register dialog.
Code:
public OnPlayerRegister(playerid, password[]) { new query[240]; if(IsPlayerConnected(playerid)) { if(GetPVarInt(playerid, "AccountExist") == 0) { new hashpass[129]; WP_Hash(hashpass, sizeof(hashpass), password); format(query, sizeof(query), "INSERT INTO accounts (Name,Pass) VALUES ('%s', '%s')", PlayerInfo[playerid][pUsername], password); mysql_function_query(handlesql, query, false, "SendQuery", ""); //==========// SetPVarInt(playerid, "Cash", 500); SetPVarInt(playerid, "Bank", 0); SetPVarInt(playerid, "Model", 26); SetPVarInt(playerid, "Interior", 0); SetPVarInt(playerid, "World", 0); SetPVarInt(playerid, "Tut", 0); SetPVarInt(playerid, "Age", 14); SetPVarInt(playerid, "Sex", 1); SetPVarFloat(playerid, "PosX", 1642.7285); SetPVarFloat(playerid, "PosY", -2240.5591); SetPVarFloat(playerid, "PosZ", 13.4945); SetPVarFloat(playerid, "Health", 50.0); SetPVarFloat(playerid, "Armour", 0.0); //==========// SetPVarInt(playerid, "AccountExist", 1); CheckAccount(playerid, 1); } else KickPlayer(playerid, "Unable to register, account exists!"); } return 1; } stock CheckAccount(playerid, type) { printf("CheckAccount is called [ID %i]", playerid); new query[82]; mysql_format(handlesql, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e'", PlayerInfo[playerid][pUsername]); print("Send a query."); mysql_pquery(handlesql, query, "OnAccountCheck", "dd", playerid, type); print("Qury sent to OnAccountCheck."); return 1; } public OnAccountCheck(playerid, type) { printf("OnAccountCheck is called [ID %i]", playerid); if(playerid != INVALID_PLAYER_ID) { new rows, fields; cache_get_data(rows, fields, handlesql); if(rows) { new fetch[24], query[256]; cache_get_field_content(0, "ConnectTime", fetch); mysql_format(handlesql, query, sizeof(query), "SELECT `deleted` FROM `accounts` WHERE `Name` = '%s'", PlayerInfo[playerid][pUsername]); mysql_pquery(handlesql, query, "OnDeletedCheck", "d", playerid); //==========// cache_get_field_content(0, "Tut", fetch); SetPVarInt(playerid, "Tut", strval(fetch)); SetPVarInt(playerid, "AccountExist", 1); if(type == 1) { SetPVarInt(playerid, "AccountExist", 1); cache_get_row(0,2,PlayerInfo[playerid][pPass],handlesql, 128); ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD,"Server Account","An existing account is using your playername, please login to the account!","Login", ""); CheckIfBanned(playerid); } } else { ShowPlayerDialog(playerid,2,DIALOG_STYLE_PASSWORD,"Server Account","There are no existing account using your playername, please create a new account!","Register", ""); } } return 1; }