Ahh, okay. Yes, the event player_disconnect is fired when a player is about to disconnect and not when he already disconnected. The reason behind that is simple: you can still access the player's attributes, functions, etc.
You can use this to work around that problem.
Syntax: Select all
from events import Event
from filters.players import PlayerIter
from players.entity import PlayerEntity
from players.helpers import index_from_userid
@Event
def player_disconnect(event):
player = PlayerEntity(index_from_userid(event.get_int('userid')))
t_count = len(list(PlayerIter('t')))
ct_count = len(list(PlayerIter('ct')))
if player.team == 2:
t_count -= 1
elif player.team == 3:
ct_count -= 1
if t_count == 0 or ct_count == 0:
engine_server.server_command('killserver;')