#!/usr/bin/php
<?php

/* Spawn zombies following every player at the start of each round.

 These settings must be set for this to work:
 ladderlog_write_game_time set to 1
 ladderlog_write_online_player set to 1
 ladderlog_game_time_interval set to 1 
 
*/

while (1)  {
    $line = rtrim(fgets(STDIN, 1024));
    if (preg_match("/^GAME_TIME/", $line)){
           $array = preg_split("/ /", $line);
           $time=floor($array[1]);
           if ( $time == 0 ) {
           print($zombie);
           $zombie="";   
           }
    }

    if (preg_match("/^ONLINE_PLAYER/", $line)){
           $array = preg_split("/ /", $line);
           if(sizeof($array)==7){
           $zombie.="SPAWN_ZONE zombie $array[1] 100 100 1 0 0 0 false .1 .2 .3 1\n";
           }
    }
}
?>