• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Releasing an Auto Restart OT script via Modern AAC!

JoSePh15_

Well-Known Member
Joined
Jan 28, 2010
Messages
1,767
Reaction score
59
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
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>]');
and add that under it:
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);
and in globalevents folder add
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
and in globalevents.xml add
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:
I was giving my sign of approval, quit acting like cuntbot over in irc c,c
 
Btw, Boyka im the one that requested it! but done it :p

@#edit
Replies: 4
Views: 45

more comments and more testers please.
 
Last edited:
gesior sux.... Modern AAC is the best! HAIL MODERN AAC!

more comments please...
 
Last edited:
as i said, gesior sux.. and i said in the beggining of the thread, i just converted the gesior version to modern aac :)
 
Shutdown would be possible through admin protocol.
 
This thingy is very cool, for example! You don't have access to your computer( if you are out or something) you can restart ur server using this.. its awesomeee! :p
 
PHP:
    if($action == "kill"){exec('TASKKILL /F /IM "'.$exename.'"'); echo ='<center>Server closed.<br><b><a href="?subtopic=restarter">Back</a></center>';}
	        echo ='<center>Server restarted.<br><b><a href="?subtopic=restarter">Back</a></center>';
        echo ='<center>Server started. <br><b><a href="?subtopic=restarter">Back</a></center>';
        echo ='<center>Server will shut down soon. <br><b><a href="?subtopic=restarter">Back</a></center>';
        echo ='<center>Server will shut down soon. <br><b><a href="?subtopic=restarter">Back</a></center>';
?subtopic in maac?
u fail#
change it ;p
 
Then go to index.php and find:
PHP:
if($ide->isAdmin())
	$smarty->assign('admin', '[<a href="'.$website.'/index.php/admin">Administration</a>]');
and add that under it:
PHP:
	$smarty->assign('admin', '[<a href="'.$website.'/index.php/p/v/restart">Restarter</a>]');

When i add that it just gives me this error:

Parse error: syntax error, unexpected T_ELSE in *\index.php on line 205
 
When i add;
Code:
$smarty->assign('admin', '[<a href="'.$website.'/index.php/p/v/restart">Restarter</a>]');

To index.php (under [code[$smarty->assign('admin', '[<a href="'.$website.'/index.php/admin">Administration</a>]');[/code]) my website get blank..
 
@Novap:
There's probably error there but your server is configured to not display them. I guess it's because there are missing brackets.
 
Parse error: syntax error, unexpected '=' in C:\xampp\htdocs\system\pages\restarter.php on line 8

Too bad.
 
Back
Top