I made mysql login register system, when it comes to login and the player enters the right password it says "WRONG", but in the second time it says "CORRECT".
Код:
new escapedPlayerName[MAX_PLAYER_NAME], escapepass[100], query[200], rows, fields, msg[256];
mysql_real_escape_string(inputtext, escapepass);
mysql_real_escape_string(GetName2(playerid), escapedPlayerName);
format(query, sizeof(query), "SELECT * FROM `users` WHERE `name` = '%s' AND `password` = '%s' LIMIT 0,1", escapedPlayerName, escapepass);
mysql_function_query(dbHandle, query, true, "", "");
cache_get_data(rows, fields);
if(rows)
{
ToggleMainMenu(playerid, 0);
OnAccountLoad(playerid);
onlinePlayers++;
gPlayerLogged[playerid] = 1;
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1642.1456,-2333.5950,-2.6797, 1.0, -1, -1, -1, -1, -1, -1);
SpawnPlayer(playerid);
format(string, sizeof(string), "~w~Welcome ~n~~y~ %s", GetName2(playerid));
GameTextForPlayer(playerid, string, 5000, 1);
}
else
{
format(msg,256,"Wrong Password %s!\nPlease enter your password and login\nWARN: You have 1 minutes to login", GetName2(playerid));
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"{FFFF00}Wrong Password!{FFFFFF}",msg,"Login","Quit");
}
The whole point of threads is that you fetch the results when the query is done. The query is not done right after it's been sent. Use a callback.
so how do I make it?...