15.01.2011, 07:49
Hello, I've got a mysql problem.
It connects and everything, but when I connect and I should be logged in automatically:
Code:
Any help will be highly appreciated, thanks in advance.
It connects and everything, but when I connect and I should be logged in automatically:
Код:
10:48:55] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection) [10:48:55] >> mysql_free_result( Connection handle: 1 ) [10:48:55] CMySQLHandler::FreeResult() - The result is already empty.
pawn Код:
public OnPlayerConnect(playerid)
{
new Query[200], Pname[24], escpname[24];
GetPlayerName(playerid, Pname, 24);
mysql_real_escape_string(Pname, escpname);
format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s'", escpname);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
new PIP[56]; //Creates the IP string
GetPlayerIp(playerid, PIP, 56);
format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `IP` = '%s'", escpname, PIP);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
new line[750];
SetPVarInt(playerid, "Logged", 1); //Sets the logged variable to 1
SendClientMessage(playerid, 0x009600AA, "Auto Logged in!");
if(mysql_fetch_row(line))
{
new data[3][50];
new data2[4];
sscanf(line, "p|ssdddds", data[0], data[1], data2[0], data2[1], data2[2], data2[3], data[2]);
SetPVarInt(playerid, "Kills", data2[0]);
SetPVarInt(playerid, "Logged", 1);
SetPVarInt(playerid, "Deaths", data2[1]);
SetPlayerScore(playerid, data2[2]);
GivePlayerMoney(playerid, data2[3]);
mysql_free_result();
}
}
if(!mysql_num_rows())
{
SendClientMessage(playerid, 0x009600AA, "This account is registered, please login");
ShowPlayerDialog(playerid, 15000, DIALOG_STYLE_INPUT , "Login", "This account is registered, please login", "OK", "Cancel");
}
}
else
{
ShowPlayerDialog(playerid, 14600, DIALOG_STYLE_INPUT , "Register", "This account is not registered, please register!", "OK", "Cancel");
SendClientMessage(playerid, 0x009600AA, "This account is not registered, please register!");
}
mysql_free_result();
return 1;
}
Any help will be highly appreciated, thanks in advance.