I assume the issue is that restarting the game would reset the achievement variables (unless you meticulously reset every game related variable manually - which would be very time consuming). I would have to functions:
Code: AGS
Then, there are two points at which you need to call each. you need to call WriteAchievements() whenever the player quits the game, or when the game is about to restart (so just before you call QuitGame(0) or RestartGame())
There are two points you should call ReadAchievements() - that is in game_start() and on_event for when the game is restored. like:Code: AGS
(all this has sort of been tested, but a long time ago)
Hope that helps
void WriteAchievements(){ //Write achievement data to file
File *i = File.Open("Achievements.dat",eFileWrite);
i.Write(Var1); //where Var are your variables
i.Write(Var2);
i.Write(Var3);
//etc etc
}
void ReadAchievements(){//Read Achievement data from file
if (!File.Exists("Achievements.dat")) return; //if the file hasn't been created yet, exit the function
File *i = File.Open("Achievements.dat",eFileRead);
Var1 = i.ReadInt();
Var2 = i.ReadInt();
Var3 = i.ReadInt();
//etc etc
}
Then, there are two points at which you need to call each. you need to call WriteAchievements() whenever the player quits the game, or when the game is about to restart (so just before you call QuitGame(0) or RestartGame())
There are two points you should call ReadAchievements() - that is in game_start() and on_event for when the game is restored. like:
function game_start(){
ReadAchievements();
}
function on_event(EventType Event, int data){
if(Event == eEventRestoreGame){ //After a reload
ReadAchievements()
}
}
(all this has sort of been tested, but a long time ago)
Hope that helps
