OnPlayerDisconnect not being called? -
xcasio - 18.11.2011
This bug is driving me nuts.
public OnPlayerConnect(playerid)
{
GetPlayerIp(playerid,String32_1,32);
format(String1024_1,1024,"INSERT INTO `live_players` (`id`,`name`,`ip`) VALUES (%d,'%s','%s')",playerid,PlayerName(playerid),Stri ng32_1);
mysql_query(String1024_1, 1, playerid);
WriteLog("temp_mysql_debug", String1024_1);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
format(String1024_1,1024,"DELETE FROM `live_players` WHERE `id` = %d",playerid);
mysql_query(String1024_1, 2, playerid);
WriteLog("temp_mysql_debug", String1024_1);
return 1;
}
Text file log extract:
[23:08:00] DELETE FROM `live_players` WHERE `id` = 55
[23:08:07] INSERT INTO `live_players` (`id`,`name`,`ip`) VALUES (55,'Toreno_Gangster','89.456.99.123')
[23:09:27] INSERT INTO `live_players` (`id`,`name`,`ip`) VALUES (55,'Jay_Player','52.972.144.47')
[23:10:22] INSERT INTO `live_players` (`id`,`name`,`ip`) VALUES (15,'Toreno_Gangster','89.456.99.123')
Player names / IPs modified to protect user privacy. As you can see, OnPlayerDisconnect isn't getting called. This happens about 0.5% of the time.
Re: OnPlayerDisconnect not being called? -
Vince - 18.11.2011
Did you actually add some debugging code to see if it's being called? Scripting is only 1% of the work, debugging takes 99% of time.
Re: OnPlayerDisconnect not being called? -
xcasio - 18.11.2011
Quote:
Originally Posted by Vince
Did you actually add some debugging code to see if it's being called? Scripting is only 1% of the work, debugging takes 99% of time.
|
Yes, that's why it's logged into a text file. Impossible to monitor it happen live since it happens to 1 out of 200 players...
Re: OnPlayerDisconnect not being called? -
Mauzen - 18.11.2011
Could be a crash in the mysql query or format then, as this would stop the rest of the function from being executed.
Maybe some special characters in the players name or something.
Re: OnPlayerDisconnect not being called? -
xcasio - 18.11.2011
The problem was the MySQL not handling long strings properly. Sadly this will be a problem for other queries that are very long..