- Joined
- Dec 11, 2007
- Messages
- 3,666
- Solutions
- 1
- Reaction score
- 125
- Location
- Warsaw, Poland
- GitHub
- tayandenga
- Twitch
- tayandenga
Okay, many people started searching this.
This is fully working feature, that doesn't cause lags like .lua ones.
1. game.cpp, around line 4200 above Game::saveServer, add:
2. game.cpp, in Game::saveData, add on begining:
3. game.h, under Game:repareServerSave(), add:
4. otserv.cpp, under:
add:
5. configmanager.cpp, under:
add:
6. configmanager.h, under:
add:
7. configmanager.h, under:
add:
Of course save the files and re-compile. Now add to config.lua values:
autoSaveEnabled = "yes"
autoSaveFrequence = 30 * 60 * 1000
Where 30 is a minutes value, change it to own use.
Code copied fastly in case of timeless Elf, specially for Ronaldino.
~yours.
This is fully working feature, that doesn't cause lags like .lua ones.
1. game.cpp, around line 4200 above Game::saveServer, add:
Code:
void Game::autoSaveData(bool savePlayers)
{
std::cout << ">> AutoSave ";
saveData(savePlayers);
Scheduler::getScheduler().addEvent(createSchedulerTask(g_config.getNumber(ConfigManager::AUTOSAVE_FREQ), boost::bind(&Game::autoSaveData, this, savePlayers)));
}
// [END] Elf
2. game.cpp, in Game::saveData, add on begining:
Code:
std::cout << "> Saving data..." << std::endl; //Elf
3. game.h, under Game:repareServerSave(), add:
Code:
void autoSaveData(bool savePlayers); //Elf
4. otserv.cpp, under:
Code:
IOLoginData::getInstance()->resetOnlineStatus();
Code:
// [START] Elf
std::cout << ">> AutoSave:";
if (g_config.getString(ConfigManager::AUTOSAVE_ENABLED) == "yes")
{
std::cout << " Enabled" << std::endl;
Scheduler::getScheduler().addEvent(createSchedulerTask(g_config.getNumber(ConfigManager::AUTOSAVE_FREQ), boost::bind(&Game::autoSaveData, &g_game, true)));
}
else
std::cout << " Disabled" << std::endl;
// [END] Elf
5. configmanager.cpp, under:
Code:
m_confString[GENERATE_ACCOUNT_NUMBER] = getGlobalString(L, "generateAccountNumber", "yes");
Code:
m_confString[AUTOSAVE_ENABLED] = getGlobalString(L, "autoSaveEnabled", "no");
m_confInteger[AUTOSAVE_FREQ] = getGlobalNumber(L, "autoSaveFrequence", 30 * 60 * 1000);
6. configmanager.h, under:
Code:
GENERATE_ACCOUNT_NUMBER,
Code:
AUTOSAVE_ENABLED,
7. configmanager.h, under:
Code:
STATUSQUERY_TIMEOUT,
Code:
AUTOSAVE_FREQ,
Of course save the files and re-compile. Now add to config.lua values:
autoSaveEnabled = "yes"
autoSaveFrequence = 30 * 60 * 1000
Where 30 is a minutes value, change it to own use.
Code copied fastly in case of timeless Elf, specially for Ronaldino.
~yours.
Last edited: