Calculating the proper setting for the UrT g_allowVote can be tricky. Because it is all about flipping bits in a binary way (just like we define the groups in B3). I've written a short and simple example/function that does just that. It makes life easier if you intend to write a plugin that needs to handle the voting settings for UrT. If you need it, use it (you can thank me in the plugin if you want

), if you don't, perhaps you can learn from it. I thought I'd share this little snippet.
First the constants list for making vote-bits readable ( usage ie.: self.VOTE_KICK ):
### voting constants ###
VOTE_RELOAD=1
VOTE_RESTART=2
VOTE_MAP=4
VOTE_NEXTMAP=8
VOTE_KICK=16
VOTE_SWAPTEAMS=32
VOTE_SHUFFLETEAMS=64
VOTE_G_FRIENDLYFIRE=128
VOTE_G_FOLLOWSTRICT=256
VOTE_G_GAMETYPE=512
VOTE_G_WAVERESPAWNS=1024
VOTE_TIMELIMIT=2048
VOTE_FRAGLIMIT=4096
VOTE_CAPTURELIMIT=8192
VOTE_G_RESPAWNDELAY=16384
VOTE_G_REDWAVERESPAWNDELAY=32768
VOTE_G_BLUEWAVERESPAWNDELAY=65536
VOTE_G_BOMBEXPLODETIME=131072
VOTE_G_BOMBDEFUSETIME=262144
VOTE_G_SURVIVORROUNDTIME=524288
VOTE_G_CAPUTURESCORETIME=1048576
VOTE_G_WARMUP=2097152
VOTE_G_MATCHMODE=4194304
VOTE_G_TIMEOUTS=8388608
VOTE_G_TIMEOUTLENGTH=16777216
VOTE_EXEC=33554432
VOTE_G_SWAPROLES=67108864
VOTE_G_MAXROUNDS=134217728
VOTE_G_GEAR=268435456
VOTE_CYCLEMAP=536870912
If you prefer a more readable form, you can easily generate the numbers (as above) with this (example) function:
v=1
VOTE_RELOAD=v
VOTE_RESTART=v<<1
VOTE_MAP=v<<2
VOTE_NEXTMAP=v<<3
VOTE_KICK=v<<4
...etcetera
The function that enables you to easily switch the different g_allowvote bits on or off:
def setVoteBit(self, bit=VOTE_KICK, state='on'):
if self.isEnabled():
_vote = self.console.getCvar('g_allowVote').getInt()
if (_vote & bit) == 0:
_currState = 'off'
else:
_currState = 'on'
if state == _currState:
return None
elif _currState == 'off':
_vote = _vote + bit
else:
_vote = _vote - bit
self.console.setCvar('g_allowVote', _vote)
return None
Ofcourse code monkeys can compress code even more. For instance:
if state == _currState:
return None
elif _currState == 'off':
_vote = _vote + bit
else:
_vote = _vote - bit
Can be replaced by:
if state == _currState:
return None
else:
_vote ^= bit
How to call this function from within your code (for instance: enabling the players to start votes for the gametype):
self.setVoteBit(VOTE_G_GAMETYPE, 'on')