SA-MP Forums Archive
On Player Crash - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: On Player Crash (/showthread.php?tid=513414)



On Player Crash - AiRaLoKa - 16.05.2014

hei all...

i got one more problem here....

is there any callback like OnPlayerCrashed?
becouse when the player is disconnected becouse of crashed, his statistic will not saved....
any ideas?

P.S.: i used BlueG's MySQL R5


Re: On Player Crash - Lordzy - 16.05.2014

When the reason on OnPlayerDisconnect gets called as 0, it means the player had timedout or might have crashed. Instead of using the functions which gets the data from the game, store them on arrays. So when the player gets disconnected, you can send a 1 second delayed timer as if you're using R5 version of MySQL to save the data to the database. However, I suggest you to use threaded queries as it's faster and efficient on such cases.

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(reason == 0) { //If it's a crash:
         //Instead of using GetPlayerMoney or GetPlayerScore, store them on an array earlier.
        //Stuffs.
    }
    return 1;
}



Re: On Player Crash - AiRaLoKa - 16.05.2014

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
When the reason on OnPlayerDisconnect gets called as 0, it means the player had timedout or might have crashed. Instead of using the functions which gets the data from the game, store them on arrays. So when the player gets disconnected, you can send a 1 second delayed timer as if you're using R5 version of MySQL to save the data to the database. However, I suggest you to use threaded queries as it's faster and efficient on such cases.

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(reason == 0) { //If it's a crash:
         //Instead of using GetPlayerMoney or GetPlayerScore, store them on an array earlier.
        //Stuffs.
    }
    return 1;
}
how to use threaded mysql?


Re: On Player Crash - Campbell- - 16.05.2014

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
When the reason on OnPlayerDisconnect gets called as 0, it means the player had timedout or might have crashed. Instead of using the functions which gets the data from the game, store them on arrays. So when the player gets disconnected, you can send a 1 second delayed timer as if you're using R5 version of MySQL to save the data to the database. However, I suggest you to use threaded queries as it's faster and efficient on such cases.

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(reason == 0) { //If it's a crash:
         //Instead of using GetPlayerMoney or GetPlayerScore, store them on an array earlier.
        //Stuffs.
    }
    return 1;
}
  1. It doesn't matter whether the player crashes, gets kicked/banned, times out or disconnects. The functions GetPlayerScore(), GetPlayerMoney(), ... work at all times in the OnPlayerDisconnect()-Callback. There is no need to save any data at all times in other data structures just for the case that a player crashes.
  2. Threaded queries are not faster at all. They just get processed on another thread of the process running to avoid the actual script to stop until the query is fully processed.
  3. Why are you still using BlueG's MySQL R5? It is outdated, filled with bugs and less efficient with less functionality.
  4. The code below works just fine ...
pawn Код:
public OnPlayerDisconnect(playerid, reason) {
    saveData(playerid);
    return 1;
}

saveData(playerid) {
    // BlueG's MySQL Plugin R38
    new query[100];
    mysql_format(handle, query, sizeof(query), "UPDATE `samp_users` SET `pScore` = %i, `pMoney` = %i WHERE `pID` = %i;", GetPlayerScore(playerid), GetPlayerMoney(playerid), playerDatabaseID);
    mysql_tquery(handle, query, "", "");
}



Re: On Player Crash - AiRaLoKa - 16.05.2014

Quote:
Originally Posted by Campbell-
Посмотреть сообщение
  1. It doesn't matter whether the player crashes, gets kicked/banned, times out or disconnects. The functions GetPlayerScore(), GetPlayerMoney(), ... work at all times in the OnPlayerDisconnect()-Callback. There is no need to save any data at all times in other data structures just for the case that a player crashes.
  2. Threaded queries are not faster at all. They just get processed on another thread of the process running to avoid the actual script to stop until the query is fully processed.
  3. Why are you still using BlueG's MySQL R5? It is outdated, filled with bugs and less efficient with less functionality.
  4. The code below works just fine ...
pawn Код:
public OnPlayerDisconnect(playerid, reason) {
    saveData(playerid);
    return 1;
}

saveData(playerid) {
    // BlueG's MySQL Plugin R38
    new query[100];
    mysql_format(handle, query, sizeof(query), "UPDATE `samp_users` SET `pScore` = %i, `pMoney` = %i WHERE `pID` = %i;", GetPlayerScore(playerid), GetPlayerMoney(playerid), playerDatabaseID);
    mysql_tquery(handle, query, "", "");
}
thanks for your explaination.....
+REP for all