Quin | 2009-05-05 21:54
AutoBot
34
points ]
 (5 votes)
Try to balance players on a Cube 2 server

This script attempts to maintain a player balance on an online server automatically.

Usage:

  • Add `exec autobot.cfg` to your autoexec.cfg
  • Claim master on any online server
  • Type `/autobot <num>` 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`

Preview:

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
]
autobot.cfg (1.5 KB)
34
points
 (5 votes)
User login
68
points ]
 (7 votes)
Created 2012-02-04 09:29
6 days 19 hours ago
Created 2012-02-10 22:32
6 hours 52 min ago
Created 2012-02-09 23:23
1 day 6 hours ago
Created 2012-02-10 11:34
17 hours 50 min ago
10
points ]
 (1 vote)
Created 2012-02-07 21:59
3 days 7 hours ago
Created 2012-01-07 16:21
4 weeks 6 days ago
8
points ]
 (1 vote)
Created 2012-02-09 20:20
1 day 9 hours ago
50
points ]
 (5 votes)
Created 2010-02-18 22:58
1 year 51 weeks ago
Created 2012-02-05 18:51
5 days 10 hours ago
Greaserpirate
20
points ]
 (3 votes)
Created 2012-01-25 03:18
2 weeks 3 days ago
Chaos
Created 2012-02-02 01:28
1 week 2 days ago
10
points ]
 (1 vote)
Created 2012-02-04 21:45
6 days 7 hours ago
15
points ]
 (2 votes)
Created 2011-10-22 17:57
15 weeks 6 days ago
13
points ]
 (4 votes)
Created 2012-01-15 14:45
3 weeks 5 days ago
Created 2012-02-02 12:37
1 week 1 day ago
14
points ]
 (2 votes)
Created 2012-02-01 01:19
1 week 3 days ago
Created 2012-01-25 00:02
2 weeks 3 days ago
Created 2012-01-27 20:51
2 weeks 8 hours ago
lopsie4
23
points ]
 (4 votes)
Created 2012-01-25 09:15
2 weeks 2 days ago
Z3R0N1C
9
points ]
 (2 votes)
Created 2012-01-30 13:01
1 week 4 days ago
Users on Quadropolis
7 guests & 1 user online