Well, it was simply because the listeners were not called if it was unable to get an index from the edict. As you can see there:
https://github.com/Source-Python-Dev-Te ... n.cpp#L416In short, it was not "working" but ignored the raised exceptions. You can do it yourself:
Syntax: Select all
@OnClientConnect
def on_client_connect(allow_connect_ptr, edict, player_name, ip_port, reject_msg_ptr, max_reject_length):
try:
index = index_from_edict(edict)
except ValueError:
return
player = Player(index) # before update it was Player(index_from_userid(index))
if player.steamid not in users:
allow_connect_ptr.set_bool(False)
reject_msg_ptr.set_string_array('Connect was blocked')
But it won't kick anyone as it will always exit the function. As you can see in the traceback you posted above, the exception is raised by the BaseEntity class initialization that cannot find the instance matching the given index (being not created at this point). Even tho you was able to get the Player instance, the steamid attribute would returns STEAM_ID_PENDING.
sl0 wrote:OnClientActive is not what we need, as i understand we can't drop connection from OnClientActive
We using `@OnClientConnect` listener for checking is player.steamid is allowed for connect to the server, if not - dropping
something like:
Syntax: Select all
@OnClientConnect
def on_client_connect(allow_connect_ptr, edict, player_name, ip_port, reject_msg_ptr, max_reject_length):
player = Player(index_from_edict(edict)) # before update it was Player(index_from_userid(index))
if player.steamid not in users:
allow_connect_ptr.set_bool(False)
reject_msg_ptr.set_string_array('Connect was blocked')
Ayuto posted a nice snippet couple months ago:
viewtopic.php?p=7955#p7955