Unmodified file when the server shuts down -
jcvag44800 - 12.04.2012
Hi guys!
I have a problem when the server goes off.
The data files not saving ...
But I created a timer that saves every two seconds but no effect ...
Here is my and my timer OnPlayerDisconnect
pawn Код:
forward Sauvegarde(playerid);
SetTimerEx("Sauvegarde", 2000, true, "is", 1337, "Timer"); // OnGameInit
public Sauvegarde(playerid)
{
  PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
  PlayerInfo[playerid][pScore] = GetPlayerScore(playerid);
  new name[MAX_PLAYER_NAME], file[256];
  GetPlayerName(playerid, name, sizeof(name));
  format(file, sizeof(file), SERVER_USER_FILE, name);
  if(gPlayerLogged[playerid] == 1)
  {
    dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
    dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
    dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
    dini_IntSet(file, "Muted",PlayerInfo[playerid][pMuted]);
    dini_IntSet(file, "Locked",PlayerInfo[playerid][pLocked]);
    dini_IntSet(file, "World",PlayerInfo[playerid][pWorld] = 0);
    dini_IntSet(file, "Kills",PlayerInfo[playerid][pKills]);
    dini_IntSet(file, "Deaths",PlayerInfo[playerid][pDeaths]);
    dini_IntSet(file, "StartRace", PlayerInfo[playerid][pStartRace]);
  }
  gPlayerLogged[playerid] = 0;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  new Year[MAX_PLAYERS], Month[MAX_PLAYERS], Day[MAX_PLAYERS], Hour[MAX_PLAYERS], Minute[MAX_PLAYERS];
  getdate(Year[playerid], Month[playerid], Day[playerid]);
  gettime(Hour[playerid], Minute[playerid]);
  PlayerInfo[playerid][pLastDay] = Day[playerid];
  PlayerInfo[playerid][pLastMois] = Month[playerid];
  PlayerInfo[playerid][pLastYear] = Year[playerid];
  PlayerInfo[playerid][pLastHeure] = Hour[playerid];
  PlayerInfo[playerid][pLastMinute] = Minute[playerid];
  PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
  PlayerInfo[playerid][pScore] = GetPlayerScore(playerid);
  new name[MAX_PLAYER_NAME], file[256];
  GetPlayerName(playerid, name, sizeof(name));
  format(file, sizeof(file), SERVER_USER_FILE, name);
  if(gPlayerLogged[playerid] == 1)
  {
    dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
    dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
    dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
    dini_IntSet(file, "Muted",PlayerInfo[playerid][pMuted]);
    dini_IntSet(file, "Locked",PlayerInfo[playerid][pLocked]);
    dini_IntSet(file, "World",PlayerInfo[playerid][pWorld] = 0);
    dini_IntSet(file, "Kills",PlayerInfo[playerid][pKills]);
    dini_IntSet(file, "Deaths",PlayerInfo[playerid][pDeaths]);
    dini_IntSet(file, "LastCo",PlayerInfo[playerid][pLastDay]);
    dini_IntSet(file, "StartRace", PlayerInfo[playerid][pStartRace]);
    dini_IntSet(file, "LastDay",PlayerInfo[playerid][pLastDay]);
    dini_IntSet(file, "LastYear",PlayerInfo[playerid][pLastYear]);
    dini_IntSet(file, "LastHeure",PlayerInfo[playerid][pLastHeure]);
    dini_IntSet(file, "LastMinute",PlayerInfo[playerid][pLastMinute]);
    dini_IntSet(file, "LastMois",PlayerInfo[playerid][pLastDay]);
  }
  gPlayerLogged[playerid] = 0;
  return 1;
}
Cordially.
Re: Unmodified file when the server shuts down -
TheArcher - 12.04.2012
This should work
pawn Код:
public OnGameModeExit()
{
  for(new i = 0; i<MAX_PLAYERS; i++)
  {
    if(!IsPlayerConnected(i)) continue;
    Sauvegarde(i);
  }
  return 1;
}
Re : Unmodified file when the server shuts down -
jcvag44800 - 12.04.2012
Not work sorry
Re: Unmodified file when the server shuts down -
ikkentim - 12.04.2012
Are you logging of all players when you close the server? ( you are testing if(gPlayerLogged[playerid] == 1); ask yourself gPlayerLogged[playerid] == 1? Yes or no ), you migh be logging the player off in OnGamemodeExit
Edit: also, how are you closing the server? Gmx/stop, closing the program, ending process?
Re : Unmodified file when the server shuts down -
jcvag44800 - 12.04.2012
All is good....
But, don't work
pawn Код:
public OnGameModeExit()
{
  for(new i=0; i<MAX_PLAYERS; i++)
  {
    new Year[MAX_PLAYERS], Month[MAX_PLAYERS], Day[MAX_PLAYERS], Hour[MAX_PLAYERS], Minute[MAX_PLAYERS];
    getdate(Year[i], Month[i], Day[i]);
    gettime(Hour[i], Minute[i]);
    PlayerInfo[i][pLastDay] = Day[i];
    PlayerInfo[i][pLastMois] = Month[i];
    PlayerInfo[i][pLastYear] = Year[i];
    PlayerInfo[i][pLastHeure] = Hour[i];
    PlayerInfo[i][pLastMinute] = Minute[i];
    PlayerInfo[i][pCash] = GetPlayerMoney(i);
    PlayerInfo[i][pScore] = GetPlayerScore(i);
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(i, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
      dini_IntSet(file, "Score", PlayerInfo[i][pScore]);
      dini_IntSet(file, "Money", PlayerInfo[i][pCash]);
      dini_IntSet(file, "AdminLevel",PlayerInfo[i][pAdminLevel]);
      dini_IntSet(file, "Muted",PlayerInfo[i][pMuted]);
      dini_IntSet(file, "Locked",PlayerInfo[i][pLocked]);
      dini_IntSet(file, "World",PlayerInfo[i][pWorld] = 0);
      dini_IntSet(file, "Kills",PlayerInfo[i][pKills]);
      dini_IntSet(file, "Deaths",PlayerInfo[i][pDeaths]);
      dini_IntSet(file, "LastCo",PlayerInfo[i][pLastDay]);
      dini_IntSet(file, "StartRace", PlayerInfo[i][pStartRace]);
      dini_IntSet(file, "LastDay",PlayerInfo[i][pLastDay]);
      dini_IntSet(file, "LastYear",PlayerInfo[i][pLastYear]);
      dini_IntSet(file, "LastHeure",PlayerInfo[i][pLastHeure]);
      dini_IntSet(file, "LastMinute",PlayerInfo[i][pLastMinute]);
      dini_IntSet(file, "LastMois",PlayerInfo[i][pLastDay]);
    return 1;
  }
  return 1;
}
Don't save
Re: Unmodified file when the server shuts down -
ikkentim - 12.04.2012
I think there is nothing wrong with this code.
You might want to try to print the file path ( print(file); ) to see if you are opening the proper file.
Also look to the 'last modified date' of the user's file to make sure this is the wonky code.
Re : Unmodified file when the server shuts down -
jcvag44800 - 12.04.2012
I'm sure its the change because the data are modified in the file.
However, when I re-connects, the variables are zero ... Finally, of the start
Re: Unmodified file when the server shuts down -
ViniBorn - 12.04.2012
pawn Код:
SetTimer("Sauvegarde", 2000, true); // OnGameModeInit
public Sauvegarde()
{
  for(new i, j = GetMaxPLayers(); i != j; i++)
  {
    if(gPlayerLogged[i] == 1)
    {
      PlayerInfo[i][pCash] = GetPlayerMoney(i);
      PlayerInfo[i][pScore] = GetPlayerScore(i);
      new name[MAX_PLAYER_NAME], file[64];
      GetPlayerName(i, name, sizeof(name));
      format(file, sizeof(file), SERVER_USER_FILE, name);
 Â
      dini_IntSet(file, "Score", PlayerInfo[i][pScore]);
      dini_IntSet(file, "Money", PlayerInfo[i][pCash]);
      dini_IntSet(file, "AdminLevel",PlayerInfo[i][pAdminLevel]);
      dini_IntSet(file, "Muted",PlayerInfo[i][pMuted]);
      dini_IntSet(file, "Locked",PlayerInfo[i][pLocked]);
      dini_IntSet(file, "World",PlayerInfo[i][pWorld] = 0);
      dini_IntSet(file, "Kills",PlayerInfo[i][pKills]);
      dini_IntSet(file, "Deaths",PlayerInfo[i][pDeaths]);
      dini_IntSet(file, "StartRace", PlayerInfo[i][pStartRace]);
    }
  }
  return true;
}
Re : Unmodified file when the server shuts down -
jcvag44800 - 12.04.2012
This callback work, but OnGameInit don't save all file...
Re: Unmodified file when the server shuts down -
ViniBorn - 12.04.2012
dini is relatively slow.
When used in OnGameModeExit, it maybe not save all files.
When player is disconnected the file is saved correctly?