<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content=text/html;charset=ISO-8859-1>
<META content="MSHTML 6.00.2900.2668" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hey, very nice one :)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Is there a similar way to dont autobalance people
from a same team.... seems to be hard to be hard to do... but at least to check
for one particular team ? with other words, is there a check on the player name
? like " if p.Name = "=SAS=*" return none ".</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Cheers</FONT></DIV>
<DIV><FONT face=Arial size=2>pAnpAn</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=giel@kingofdos.com href="mailto:giel@kingofdos.com">Giel van
Schijndel</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=bf1942@icculus.org
href="mailto:bf1942@icculus.org">bf1942 icculus</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, July 04, 2005 11:00
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [bf1942] autobalance
system</DIV>
<DIV><FONT face=Arial size=2></FONT><BR></DIV>I've modified the autobalance.py
script because it kinda pissed me off after being switched for the third time
while being a commander.<BR><BR>I have simply added these lines in the
onPlayerDeath() routine:<BR>These lines should ensure that the Commander and
Squad Leader will NOT be switched
anymore.<BR><BR> # [Modification]
This tiny piece of code added makes sure that the Commander and Squad Leader
are immune for being
teamswitched.<BR> if
p.isCommander():<BR>
return None<BR><BR> if
p.isSquadLeader():<BR>
return None<BR> #
[/Modification]<BR><BR><BR>cheers,<BR><BR>
<DIV class=moz-signature>-- <BR><BIG><FONT face=Verdana size=-2><BIG><!-- SGT -->Mortis - Webadmin and Game Server admin<BR>European
Tactical Battlefield Forces<!--<a href="http://www.theartofwarfare.net">The Art Of Warfare</a> - BF<br>
The Gryphons--></BIG></FONT></BIG></DIV>
<P>
<HR>
<P></P># team autobalance system<BR><BR>import bf2<BR>import host<BR>from bf2
import g_debug<BR><BR>def
init():<BR> if g_debug: print
'initializing autobalance
script'<BR><BR>
host.registerHandler('PlayerConnect',
onPlayerConnect)<BR>
host.registerHandler('PlayerDeath',
onPlayerDeath)<BR>
host.registerHandler('PlayerChangeTeams', onPlayerChangeTeams)<BR><BR><BR>def
onPlayerConnect(p):<BR> # if not
bf2.serverSettings.getAutoBalanceTeam(): return
None<BR> if g_debug: print 'place
player on the team with least
players'<BR><BR> team1 =
0<BR> team2 =
0<BR> for tp in
bf2.playerManager.getPlayers():<BR>
if tp !=
p:<BR>
if tp.getTeam() == 1: team1 +=
1<BR>
else: team2 += 1<BR><BR> team2 =
team2 * bf2.serverSettings.getTeamRatioPercent() /
100.0<BR> if team2 >
team1:<BR>
p.setTeam(1)<BR>
else:<BR>
p.setTeam(2)<BR><BR>def onPlayerDeath(p,
vehicle):<BR> if not
bf2.serverSettings.getAutoBalanceTeam(): return
None<BR> if g_debug: print 'handling
player death autobalance'<BR><BR> #
dont use autobalance when its suicide/changes
team<BR> if
p.getSuicide():<BR>
p.setSuicide(0)<BR>
return None<BR><BR> # [Modification]
This tiny piece of code added makes sure that the Commander and Squad Leader
are immune for being
teamswitched.<BR> if
p.isCommander():<BR>
return None<BR><BR> if
p.isSquadLeader():<BR>
return None<BR> #
[/Modification]<BR><BR>
aiPlayerBalance = 0<BR> team1 =
0<BR> team2 =
0<BR> for tp in
bf2.playerManager.getPlayers():<BR>
if tp.getTeam() ==
1:<BR>
team1 +=
1<BR>
else:<BR>
team2 +=
1<BR>
if
tp.isAIPlayer():<BR>
aiPlayerBalance +=
1<BR>
else:<BR>
aiPlayerBalance -= 1<BR><BR> if
host.sgl_getIsAIGame():<BR>
if not (aiPlayerBalance <
0):<BR>
if not
p.isAIPlayer():<BR>
return None<BR><BR> team2 = team2 *
bf2.serverSettings.getTeamRatioPercent() /
100.0<BR> if g_debug: print 'team1
%f team2 %f' % (team1,team2)<BR> if
(p.getTeam() ==
1):<BR>
if (team2+1) <
team1:<BR>
p.setTeam(2)<BR> elif (p.getTeam()
==
2):<BR>
if (team1+1) <
team2:<BR>
p.setTeam(1)<BR><BR>def onPlayerChangeTeams(p,
humanHasSpawned):<BR> if not
bf2.serverSettings.getAutoBalanceTeam(): return
None<BR> if
host.sgl_getIsAIGame():<BR>
if humanHasSpawned: return
None<BR>
if p.isAIPlayer(): return
None<BR><BR>
if g_debug: print 'handling aiplayer team change autobalance when round not
started'<BR><BR>
team =
p.getTeam()<BR>
aiplayer =
0<BR><BR>
for tp in
bf2.playerManager.getPlayers():<BR>
if aiplayer == 0 and tp.getTeam() == team and
tp.isAIPlayer():<BR>
aiplayer =
tp<BR>
break<BR><BR>
if
aiplayer:<BR>
if p.getTeam() == 1:
aiplayer.setTeam(2)<BR>
else: aiplayer.setTeam(1)<BR><BR>
else:<BR>
if g_debug: print 'checking to see if player is allowed to change
teams'<BR><BR>
team1 =
0<BR>
team2 =
0<BR>
for tp in
bf2.playerManager.getPlayers():<BR>
if tp.getTeam() == 1: team1 +=
1<BR>
else: team2 +=
1<BR>
if abs(team1 - team2) >
1:<BR>
if p.getTeam() == 1:
p.setTeam(2)<BR>
else: p.setTeam(1)<BR><BR><BR></BLOCKQUOTE></BODY></HTML>