Hi again!
Once I managed to make the lock work, I noticed that a forced player will receive 4 B3 PM when he tries to change team.
Let's say a user has been forced in red.
When he tried to go back to blue, the following events happen:
- User changes team:
--- TEAM_CHANGE with team = -1 (b3.TEAM_UNKNOWN)
--- TEAM_CHANGE with team = 3 (b3.TEAM_BLUE)
- B3 forces the user back to red:
--- TEAM_CHANGE with team = -1 (b3.TEAM_UNKNOWN)
--- TEAM_CHANGE with team = 2 (b3.TEAM_RED)
PowerAdminUrt is notified for each of these events, and thus enters this block of code, 4 times:
if not self._matchmode and client.isvar(self, 'paforced')
team = client.var(self, 'paforced').value
self.console.write('forceteam %s %s' % (client.cid, team))
client.message('^1You are LOCKED! You are NOT allowed to switch!')
self.verbose('%s was locked and forced back to %s' %(client.name, team))
# Break out of this function, nothing more to do here
return None
To make sure the user is only notified once, I changed the code to the following:
if not self._matchmode and client.isvar(self, 'paforced'):
forcedTeam = client.var(self, 'paforced').value
if team != b3.TEAM_UNKNOWN and team != self.console.getTeam(forcedTeam):
self.console.write('forceteam %s %s' % (client.cid, forcedTeam))
client.message('^1You are LOCKED! You are NOT allowed to switch!')
self.verbose('%s was locked and forced back to %s' %(client.name, forcedTeam))
# Break out of this function, nothing more to do here
return None
Also, because it does not really make sense to force a player permanently, I wanted to add the following in the disconnect event, to unlock a player when he disconnects from the server:
if event.type == b3.events.EVT_CLIENT_DISCONNECT:
[...]
if (event.client.isvar(self, 'paforced')):
event.client.delvar(self, 'paforced')
But it does not work, because there is no "event.client" variable.
I wanted to do that because the main issue, currently, with lock, is that if there is no admin to unlock the player, well, the player is locked in a team forever. And it kinda sucks

. My solution would not have been perfect either, because the player could disconnect and come back to choose his team, but I think it would be more annoying for them after 2-3 map loads :p.
I guess the best thing would be to have TempLocks, just like the way we have TempBans, like: lock a player in a team for 10 minutes, etc.
What do you guys think?