#!/usr/bin/php <?php /*cfg rotation script by dukevin. The cfg files must not be in a folder. Edit settings below:*/ //Add as many or as little .cfg's as you want in the line below, separated by a comma: $cfglist=array("mycfg1.cfg","mycfg2.cfg","mycfg3.cfg","mycfg4.cfg"); //Play a cfg this many times before switching to the next one: $rounds = 1; //Display how many rounds before the cfg changes? Alerts not displayed if $rounds = 1 $alert = true; //set to "true" if yes, "false" if no /*======================================================================*/ /*======================================================================*/ $played = array(); $last = -1; $played = array_fill(0, count($cfglist), 0); while(true){ $repeating = false; $line = rtrim(fgets(STDIN, 1024)); if (preg_match("/^ROUND_COMMENCING/", $line)) { for($x=0; $x<(sizeof($cfglist)); $x++) { if(($played[$x] < $rounds && $played[$x] != 0)) { $played[$x]++; echo "INCLUDE ". ($cfglist[$x]) ." \n"; if ($rounds > 1 && $alert) echo "CONSOLE_MESSAGE 0xaaaaaa{$cfglist[$x]} will play for ". ($rounds-$played[$x]) ." more round(s).\n"; $repeating = true; break; } } if(!$repeating) { if(min($played) == $rounds) //all the cfgs have been played { echo "console_message Recycling...\n"; $played = array_fill(0, count($cfglist), 0); } do $num = mt_rand(0,(sizeof($cfglist)-1)); while(($played[$num]>=$rounds)||$last==$num); $last = $num; echo "INCLUDE ". ($cfglist[$num]) ." \n"; $played[$num]++; if ($rounds > 1 && $alert) echo "CONSOLE_MESSAGE 0xaaaaaa{$cfglist[$num]} will play for ". ($rounds-$played[$x]) ." more rounds.\n"; } } } ?>