underewar 32 #1 Posted March 3, 2019 Um código simples para fazer o global server save, e logo após reiniciar o servidor. Windows Adicione no Config.Lua Spoiler shutdownAtGlobalSave = true globalSaveEnabled = true No Game.cpp adicione uma nova função bool Game::isRunning(const char* name) { PROCESSENTRY32 proc32; HANDLE hSnapshot; hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); proc32.dwSize = sizeof(PROCESSENTRY32); bool isRunning = false; if(Process32First(hSnapshot, &proc32)) { while(Process32Next(hSnapshot, &proc32)) { std::string filename_str = std::string(proc32.szExeFile); if(filename_str == name) { isRunning = true; break; } } } CloseHandle(hSnapshot); return isRunning; } Adicione em game.h bool isRunning(const char* name); Em Game.cpp procure por void Game::setGameState(GameState_t newState) E adicione logo a baixo. Scheduler::getInstance().stop(); Dispatcher::getInstance().stop(); E abaixo disso adicione const char* name = "AutoRun.exe"; if(!isRunning(name)) WinExec(name, SW_SHOWNORMAL); Em otsystem.h adicione um novo include #include <windows.h> Agora vamos anexar isso #include <tlhelp32.h> Esta feito agora basta compilar um programa chamado autorun.exe com o código a baixo. Após a compilação coloque o exe na pasta do servidor e inicie. Spoiler #include <windows.h> #include <tlhelp32.h> #include <iostream> const int _time = 10; char* name = "servidor.exe"; bool isRunning() { PROCESSENTRY32 proc32; HANDLE hSnapshot; hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); proc32.dwSize = sizeof(PROCESSENTRY32); std::cout << "Check the server is running." << std::endl; bool isRunning = false; if(Process32First(hSnapshot, &proc32)) { while(Process32Next(hSnapshot, &proc32)) { std::string filename_str = std::string(proc32.szExeFile); if(filename_str == name) { isRunning = true; break; } } } CloseHandle(hSnapshot); return isRunning; } bool checkServer() { while(true) { Sleep(_time * 1000); if(!isRunning()) { std::cout << "Run the server." << std::endl; WinExec(name, SW_SHOWNORMAL); return true; } } return false; } int main() { if(checkServer()) return 0; return 1; } Linux: Spoiler Desative em Em otserv.cpp , procure por : { #if defined(WINDOWS) && !defined(__CONSOLE__) if(MessageBox(GUI::getInstance()->m_mainWindow, "Unable to fetch blacklist! Continue?", "Blacklist", MB_YESNO) == IDNO) #else std::cout << "Unable to fetch blacklist! Continue? (y/N)" << std::endl; char buffer = getchar(); if(buffer == 10 || (buffer != 121 && buffer != 89)) #endif startupErrorMessage("Unable to fetch blacklist!"); } substitua por : /*{ #if defined(WINDOWS) && !defined(__CONSOLE__) if(MessageBox(GUI::getInstance()->m_mainWindow, "Unable to fetch blacklist! Continue?", "Blacklist", MB_YESNO) == IDNO) #else std::cout << "Unable to fetch blacklist! Continue? (y/N)" << std::endl; char buffer = getchar(); if(buffer == 10 || (buffer != 121 && buffer != 89)) #endif startupErrorMessage("Unable to fetch blacklist!"); }*/ Agora no Terminal: while true; do ./theforgottenserver -y; done Creditos: Underewar 1 Majesty reacted to this Share this post Link to post
Majesty 1,755 #2 Posted March 3, 2019 Muito obrigado pela sua contribuição, seu tópico de conteúdo foi aprovado! Nós do OTServ Brasil agradecemos, seu conteúdo com certeza ajudará a muitos outros. Você recebeu +1 REP! Share this post Link to post