// autobot: Try to balance players on a Cube 2 server // (C) 2009 Quinton "quin" Reeves, ZLIB license // http://www.opensource.org/licenses/zlib-license.php // Usage: // - Add `exec autobot.cfg` to your autoexec.cfg // - Claim master on any online server // - Type `/autobot ` where num is the number of players to balance (optional) // - Relax and let the script manage balancing for you :) // - To turn off, type `/autobot 0` maxautobot = 8 // maximum number of bots we can add balautobot = 8 // attempt to keep this many players runautobot = [ cln = (listclients 1) bot = 0; ppl = 0 loop i (listlen $cln) [ num = (at $cln $i) if (= (isspectator $num) 0) [ ppl = (+ $ppl 1) if (strcmp (getclientname $num) bot) [ // not ideal, but it works bot = (+ $bot 1) ] ] ] if (> $balautobot 0) [ amt = (- $balautobot $ppl) if (> $amt 0) [ if (> (+ $bot $amt) $maxautobot) [ amt = (- $maxautobot $bot) ] if (mod (+ $ppl $amt) 2) [ amt = (- $amt 1) ] if (> $amt 0) [ loop i $amt [ addbot ] ] ] [ amt = (- 0 $amt) if (> $amt 0) [ if (> $amt $bot) [ amt = $bot ] if (mod (- $ppl $amt) 2) [ amt = (+ $amt 1) ] if (> $amt 0) [ loop i $amt [ delbot ] ] ] ] ] [ if (> $bot 0) [ loop i $bot [ delbot ] ] ] ] doautobot = [ runautobot if (&& (= $balautobot $arg1) (> $balautobot 0)) [ sleep 1000 [ doautobot $balautobot ] // rinse, repeat ] ] autobot = [ if (> $numargs 0) [ balautobot = $arg1 ] doautobot $balautobot ]