28.06.2014, 00:00
Hello guys, I was reading a MySQL login/register tutorial. I was going to edit it for my needs as soon as I make sure it is working perfect. Everything is fine, it says MySQL database is connected etc. But when I connect to server, I see no log-in nor register dialogs. Here is the codes:
and here is the "OnAccountCheck" callback:
pawn Код:
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid,-1,"{FF0000}(( {00FF00}[INFO]: {FFFFFF}Please wait while you are getting synced with the database. {FF0000}))");
StopStats(playerid);
new query[128];
GetPlayerName(playerid, Name[playerid], 24);
mysql_format(mysql, query, sizeof(query),"SELECT `Password`, `ID` FROM `server` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
return 1;
}
pawn Код:
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(0, "PASS", pInfo[playerid][Password], mysql, 129);
pInfo[playerid][sqlID] = cache_get_field_content_int(0, "sqlID");
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login", "Login", "Quit");
}
else
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.", "Register", "Quit");
}
return 1;
}