28.02.2012, 14:46
in case the mysql database doesnt respond for a moment (or connection dead)
the rows returned would be equal to 0 right?
So that would cause a re-registration of an allready existing member right?
So i made a ping code to check if the connection is still alive before going on with login.
Would that be ok or is it kinda senseless?
the rows returned would be equal to 0 right?
So that would cause a re-registration of an allready existing member right?
So i made a ping code to check if the connection is still alive before going on with login.
Would that be ok or is it kinda senseless?
pawn Code:
//OnPlayerConnect
if(!mysql_ping())//connection alive
{
new pnameq[24],query[128];
GetPlayerName(playerid,pnameq,24);
format(query, sizeof(query), "SELECT name FROM `ACCOUNTS` WHERE name = '%s' LIMIT 1", pnameq);
mysql_query(query);
mysql_store_result();
new rows = mysql_num_rows();
if(!rows)
{
//Register script, would INSERT new accounts
}
else if(rows == 1)
{
//Login script, would continue the old account
}
}
else//connection dead so reconnect to database
{
print("Reconnecting to the MYSQL Database...");
new MySQL:connection = mysql_init(LOG_ONLY_ERRORS, 1);
mysql_connect(mysql_host, mysql_user, mysql_password,mysql_database,connection,1);
}