#!/usr/bin/php
<?php
//Any admin can type /killall and everyone on grid will die
//Made by dukevin
while (1) {
$line = rtrim(fgets(STDIN, 1024));
if(preg_match("/^CYCLE_CREATED/", $line))
{
	$split = explode(" ",$line);
	$name = $split[1];
	$players[] = $name;
}
if(preg_match("/^INVALID_COMMAND/", $line))
{
	$split = explode(" ", $line);
	if($split[4] > 1 && $split[1] == "/killall")
	{
		echo "player_message $split[2] \"0xff7777You need to be admin to kill everyone.\"\n ";
	}
	else if($split[1] == "/killall")
	{
		echo "center_message Apocalypse!\n";
		foreach($players as $p)
			echo "kill $p\n";
	}
}
if(preg_match("/^ROUND_COMMENCING/", $line))
	unset($players);
}
?>