User data saving
#1

Hi guys.
I have made a gamemode that saves and loads user data using Dini.
I thourght about makeing a timer that saves the user data every second, so that the data are not only saved when the player disconnects. Is this a good idea? If not, what could the alternative be?

Thank you.
Reply
#2

For me the best variant its

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    switch(reason)
    {
        case 0: SaveData(playerid); // You'r function
        case 1: SaveData(playerid); // You'r function
        case 2: SaveData(playerid); // You'r function
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Raimis_R
Посмотреть сообщение
For me the best variant its

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    switch(reason)
    {
        case 0: SaveData(playerid); // You'r function
        case 1: SaveData(playerid); // You'r function
        case 2: SaveData(playerid); // You'r function
    }
    return 1;
}
And what if the server restarts or he loses connection to the internet?
Reply
#4

It's better to save user's data when he disconnects. Because if you save user's data every second it could make lagg.

Quote:
Originally Posted by sim_sima
Посмотреть сообщение
And what if the server restarts or he loses connection to the internet?
It will save user's data because OnPlayerDisconnect() callback will be call.
Reply
#5

Well, I save player information every 60 seconds and it doesn't cause lagg at all.
Reply
#6

Quote:
Originally Posted by sim_sima
Посмотреть сообщение
And what if the server restarts or he loses connection to the internet?
So here is 3 reasons

Left Game
Kicked/Banned
Crashed
Reply
#7

Quote:
Originally Posted by Raimis_R
Посмотреть сообщение
For me the best variant its

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    switch(reason)
    {
        case 0: SaveData(playerid); // You'r function
        case 1: SaveData(playerid); // You'r function
        case 2: SaveData(playerid); // You'r function
    }
    return 1;
}
Or just:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
   SaveData(playerid);
   return 1;
}
Reply
#8

you should do both, but 1 second is too quick, maybe every 10 minutes
Reply
#9

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Or just:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
   SaveData(playerid);
   return 1;
}
I already did that, and it doesnt work when the server restarts, because OnPlayerDisconnect only gets called when the player disconnects.
Reply
#10

Ok, i tryed this:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    switch(reason)
    {
        case 0: SaveData(playerid); // You'r function
        case 1: SaveData(playerid); // You'r function
        case 2: SaveData(playerid); // You'r function
    }
    return 1;
}
Well, it totally fucks up. My script saves position, and when i spawn, i just die and get freezed, unable to move :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)