Olá xtibianos, vim trazer um script que acredito eu seja um pouco útil e facilite a vida de algumas pessoas...
Bom o script é simples você tem total controle sobre seu servidor pelo site, exemplo: você pode fechar ele, abrir, reiniciar tudo através do site do servidor.
bom vamos ao que interessa
na pasta htdocs do seu site faça um arquivo .php chamado restarter e cole isso:
<?PHP $path = $config['site']['server_path']; $exename = "NOME DO EXECUTAVEL.exe"; if($group_id_of_acc_logged >= $config['site']['access_admin_panel']) { if($action == "") { $main_content .= '<table style=\'clear:both\' border=0 cellpadding=0 cellspacing=0 width=\'100%\'> <tr bgcolor='.$config['site']['darkborder'].'><td width="150"><font color="red"><b>Option</b></font></td><td><font color="red"><b>Description</b></font></td></tr> <tr bgcolor='.$config['site']['lightborder'].'><td width="150"><b><a href="?subtopic=restarter&action=restart">Reiniciar</a></b></td><td><b>Fechar o servidor e abri-lo novamente</b></td></tr> <tr bgcolor='.$config['site']['darkborder'].'><td width="150"><b><a href="?subtopic=restarter&action=kill">Fechar Servidor</a></b></td><td><b>Fechar todos os processos do servidor imediatamente</b></td></tr> <tr bgcolor='.$config['site']['lightborder'].'><td width="150"><b><a href="?subtopic=restarter&action=start">Iniciar Servidor</a></b></td><td><b>iniciar servidor</b></td></tr> <tr bgcolor='.$config['site']['darkborder'].'><td width="150"><b><a href="?subtopic=restarter&action=shutdown">Fechar o servidor</a></b></td><td><b>Fecha o servidor após 5 minutos</b></td></tr> <tr bgcolor='.$config['site']['lightborder'].'><td width="150"><b><a href="?subtopic=restarter&action=shutdownlong">avisar os players do fechamento do servidor</a></b></td><td><b>Performs safe shutdown after broadcast warning and 5 minutes delay.</b></td></tr> <tr bgcolor='.$config['site']['darkborder'].'><td width="150"><b><a href="?subtopic=adminpanel">Back to admin panel</a></b></td><td><b>Go back to admin panel.</b></td></tr> </table>'; } getcwd(); chdir($path); if($action == "restart") { exec('TASKKILL /F /IM "'.$exename.'"'); $command = 'START/HIGH '.$exename; $tmpnam = "temp.bat"; $fp = fopen ($tmpnam, "w"); fwrite($fp, $command); fclose ($fp); $foo = @popen($tmpnam, 'r'); $main_content .='<center>Server restarted.<br><b><a href="?subtopic=restarter">Back</a></center>'; } if($action == "kill"){exec('TASKKILL /F /IM "'.$exename.'"'); $main_content .='<center>Server closed.<br><b><a href="?subtopic=restarter">Back</a></center>';} if($action == "start") { $command = 'START/HIGH '.$exename; $tmpnam = "temp.bat"; $fp = fopen ($tmpnam, "w"); fwrite($fp, $command); fclose ($fp); $foo = @popen($tmpnam, 'r'); $main_content .='<center>Server started. <br><b><a href="?subtopic=restarter">Back</a></center>'; } if($action == "shutdown") { $SQL->query('UPDATE '.$SQL->tableName('z_shut').' SET `shutdown`="1", `long`="0" WHERE id = "1";'); $main_content .='<center>Server will shut down soon. <br><b><a href="?subtopic=restarter">Back</a></center>'; } if($action == "shutdownlong") { $SQL->query('UPDATE '.$SQL->tableName('z_shut').' SET `shutdown`="1", `long`="1" WHERE `id` = "1";'); $main_content .='<center>Server will shut down soon. <br><b><a href="?subtopic=restarter">Back</a></center>'; } } else { $title = $GLOBALS['config']['server']["serverName"]." - OTS"; $main_content .= 'Invalid subtopic. Can\'t load page.'; } ?>
Não esqueçam de colocar o nome do executável do servidor na 3º linha!
agora vá em index.php e adicione:
case "restarter": $topic = "Restarter"; $subtopic = "restarter"; include("restarter.php"); break;
Antes de:
case "latestnews": $topic = "Latest News"; $subtopic = "latestnews"; include("latestnews.php"); break;
Agora em adminpanel.php adicione:
<tr bgcolor='.$config['site']['lightborder'].'><td width="150"><b><a href="?subtopic=restarter">Restarter</a></b></td><td><b>Here you start, stop and restart server!</b></td></tr>
Antes de
</table>
Agora na sua database execute isso:
CREATE TABLE IF NOT EXISTS `z_shut` ( `id` int(11) NOT NULL AUTO_INCREMENT, `shutdown` int(11) NOT NULL DEFAULT '1', `long` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; INSERT INTO `z_shut` (`id`, `shutdown`, `long`) VALUES (1, 0, 1);
agora na pasta do seu servidor vá em data\globalevents\scripts faça um novo arquivo .lua com o nome de restarter e cole isso:
local message = { "Server will shut down in 5 minutes. Dont ask me why, I'm only script", "Server will shutdown in 2 minutes, please log off", "Server is going down..." } local class = 21 function shutDown() doBroadcastMessage(message[3], class) doSetGameState(GAMESTATE_SHUTDOWN) return TRUE end function broadcast() doBroadcastMessage(message[2], class) return TRUE end function onThink(interval, lastExecution) local result_plr = db.getResult("SELECT * FROM z_shut WHERE `id` = 1;") if(result_plr:getID() ~= -1) then while(true) do if(tonumber(result_plr:getDataInt("shutdown"))==1) then db.executeQuery("UPDATE z_shut SET shutdown = '0' WHERE id = '1';") if(tonumber(result_plr:getDataInt("long"))==0) then doBroadcastMessage(message[3], class) doSetGameState(GAMESTATE_SHUTDOWN) else doBroadcastMessage(message[1], class) addEvent(broadcast, 3*60*1000, {}) addEvent(shutDown, 5*60*1000, {}) end end if not(result_plr:next()) then break end end end result_plr:free() return TRUE end
e por fim em globalevents.xml adicione:
<globalevent name="safe_shutdown" interval="5" event="script" value="restarter.lua"/>
Sinceramente espero que seja útil para vocês isso, duvidas podem postar que estarei ajudando...