Syntax: Select all
from events.hooks import PreEvent, EventAction
from messages import SayText2
from players._base import Player
from players.helpers import index_from_userid
@PreEvent('player_team')
def on_player_team(event):
player = Player(index_from_userid(event['userid']))
SayText2('Detect player change team').send(player.index)
if event['isbot'] or event['disconnect']:
SayText2('Player is bot or disconnecting.').send(player.index)
return
if event['oldteam'] in [2, 3] and event['team'] in [2, 3]:
SayText2('Avoid changing team please.').send(player.index)
return EventAction.BLOCK
When I as a player press default "m", I change team. I get 'Avoid changing team please.' message in chat and team change event is commited. "teamchange_pending" and "switch_team" events are not triggered during process.