29.01.2017, 15:07
Quote:
I won't talk too much, I have debugged what you have said above just to show that your statements are wrong. Well, I have made a message prints to the log once the server shuts down with the "/rcon exit" method.
My OnPlayerDisconnect Code: Код:
public OnPlayerDisconnect(playerid, reason) { Corrupt_Check[playerid]++; new DB_Query[256]; //Running a query to save the player's data using the stored stuff. mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `PLAYERS` SET `SCORE` = %d, `CASH` = %d, `KILLS` = %d, `DEATHS` = %d WHERE `ID` = %d LIMIT 1", pInfo[playerid][Score], pInfo[playerid][Cash], pInfo[playerid][Kills], pInfo[playerid][Deaths], pInfo[playerid][ID]); mysql_tquery(Database, DB_Query); if(cache_is_valid(pInfo[playerid][Player_Cache])) //Checking if the player's cache ID is valid. { cache_delete(pInfo[playerid][Player_Cache]); // Deleting the cache. pInfo[playerid][Player_Cache] = MYSQL_INVALID_CACHE; // Setting the stored player Cache as invalid. } pInfo[playerid][LoggedIn] = 0; print("OnPlayerDisconnect has been called."); // Sending message once OnPlayerDisconnect is called. return 1; } Код:
[13:40:00] [connection] 10.42.0.74:61008 requests connection cookie. [13:40:01] [connection] incoming connection: 10.42.0.74:61008 id: 0 [13:40:01] [join] Variable has joined the server (0:10.42.0.74) [13:40:12] RCON (In-Game): Player #0 (Variable) has logged in. [13:40:14] RCON (In-Game): Player [Variable] sent command: exit [13:40:14] --- Server Shutting Down. [13:40:14] OnPlayerDisconnect has been called. [13:40:15] [part] Variable has left the server (0:0) Hopefully you'll next time make sure of what you state before you do and thanks. You can also try that by yourself. ======================================= Would like to make sure the OnPlayerDisconnect doesn't get called twice? Here's another evidence! When I removed the part from OnGameModeExit, the message didn't show anymore. Код:
public OnGameModeExit() { /* for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) // Getting the highest player ID in the game. { if(IsPlayerConnected(i)) // Checking if the players stored in "i" are connected. { OnPlayerDisconnect(i, 1); // We do that so players wouldn't lose their data upon server's close. } }*/ mysql_close(Database); // Closing the database. return 1; } Код:
public OnPlayerDisconnect(playerid, reason) { Corrupt_Check[playerid]++; new DB_Query[256]; //Running a query to save the player's data using the stored stuff. mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `PLAYERS` SET `SCORE` = %d, `CASH` = %d, `KILLS` = %d, `DEATHS` = %d WHERE `ID` = %d LIMIT 1", pInfo[playerid][Score], pInfo[playerid][Cash], pInfo[playerid][Kills], pInfo[playerid][Deaths], pInfo[playerid][ID]); mysql_tquery(Database, DB_Query); if(cache_is_valid(pInfo[playerid][Player_Cache])) //Checking if the player's cache ID is valid. { cache_delete(pInfo[playerid][Player_Cache]); // Deleting the cache. pInfo[playerid][Player_Cache] = MYSQL_INVALID_CACHE; // Setting the stored player Cache as invalid. } pInfo[playerid][LoggedIn] = 0; print("OnPlayerDisconnect has been called."); // Sending message once OnPlayerDisconnect is called. return 1; } Код:
[13:57:34] [connection] 10.42.0.74:61529 requests connection cookie. [13:57:35] [connection] incoming connection: 10.42.0.74:61529 id: 0 [13:57:35] [join] Variable has joined the server (0:10.42.0.74) [13:57:49] RCON (In-Game): Player #0 (Variable) has logged in. [13:57:52] RCON (In-Game): Player [Variable] sent command: exit [13:57:52] --- Server Shutting Down. [13:57:52] [part] Variable has left the server (0:0) For "/rcon gmx" method
|
But anyways gamemode exit happens only once or twice in a long time period unless your mode requires gamemode switching for new rounds/games, where this could be concern for developers.