Hello guys, today i'm releasing an auto restarter to Modern AAC!
I would like to say that the original thread was done by Zakius, and i just converted it to Modern AAC.
This is just for Windows!
Ok, so lets start!
in \system\pages and make a new file called restarter.php and add
Then go to index.php and find:
and add that under it:
Now in phpmyadmin, execute
and in globalevents folder add
and in globalevents.xml add
That's all! I didn't test it btw, so test it and tell me if it works!
Please report any bugs...
And feel free to rep++ me!
I would like to say that the original thread was done by Zakius, and i just converted it to Modern AAC.
This is just for Windows!
Ok, so lets start!
in \system\pages and make a new file called restarter.php and add
PHP:
<?PHP
$path = "Folder Path Here";
$exename = "TheForgottenServer.exe";
if($ide->isAdmin())
{
if($action == "")
{
echo = '<table style=\'clear:both\' border=0 cellpadding=0 cellspacing=0 width=\'100%\'>
<tr><td width="150"><font color="red"><b>Option</b></font></td><td><font color="red"><b>Description</b></font></td></tr>
<tr bgcolor="#cccccc"><td width="150"><b><a href=\"'.$website.'/index.php/p/v/restart&action=restart\">Restart</a></b></td><td><b>Kills server process and starts new one.</b></td></tr>
<tr><td width="150"><b><a href=\"'.$website.'/index.php/p/v/restart&action=kill\">Kill process</a></b></td><td><b>Kills server process.</b></td></tr>
<tr bgcolor="#cccccc"><td width="150"><b><a href=\"'.$website.'/index.php/p/v/restart&action=start\">Start server</a></b></td><td><b>Starts server.</b></td></tr>
<tr><td width="150"><b><a href=\"'.$website.'/index.php/p/v/restart&action=shutdown\">Shutdown server instantly</a></b></td><td><b>Allows you to safe shutdown server(using servers own shutdown function).</b></td></tr>
<tr bgcolor="#cccccc"><td width="150"><b><a href=\"'.$website.'/index.php/p/v/restart&action=shutdownlong\">Player-friendly shutdown</a></b></td><td><b>Performs safe shutdown after broadcast warning and 5 minutes delay.</b></td></tr>
<tr><td width="150"><b><a href="'.$website.'/index.php/admin">Back to Administration</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');
echo ='<center>Server restarted.<br><b><a href="?subtopic=restarter">Back</a></center>';
}
if($action == "kill"){exec('TASKKILL /F /IM "'.$exename.'"'); echo ='<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');
echo ='<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";');
echo ='<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";');
echo ='<center>Server will shut down soon. <br><b><a href="?subtopic=restarter">Back</a></center>';
}
}
else
{
$title = $GLOBALS['config']['server']["serverName"]." - OTS";
echo = 'Invalid subtopic. Can\'t load page.';
}
?>
Then go to index.php and find:
PHP:
if($ide->isAdmin())
$smarty->assign('admin', '[<a href="'.$website.'/index.php/admin">Administration</a>]');
PHP:
$smarty->assign('admin', '[<a href="'.$website.'/index.php/p/v/restart">Restarter</a>]');
Now in phpmyadmin, execute
SQL:
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);
Lua:
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
XML:
<globalevent name="safe_shutdown" interval="5" event="script" value="restarter.lua"/>
That's all! I didn't test it btw, so test it and tell me if it works!
Please report any bugs...
And feel free to rep++ me!
Last edited: