Page 1 of 1

Player connect event missing index?

Posted: Sat May 22, 2021 9:27 pm
by Zeus
Hello hopefully this is a simple problem.

I need to apply attributes to a player when they join the server. I need their steamid to lookup some info about them.
Currently im catching the "player_connect" event since it gives me index and steam id.

Upon connecting though; the server doesnt seem to assign an index until a couple seconds after this event fires. Is there a different event I should catch?

Re: Player connect event missing index?

Posted: Sat May 22, 2021 9:45 pm
by VinciT
You could use the OnClientActive listener:

Syntax: Select all

# ../client_active/client_active.py

# Source.Python
from listeners import OnClientActive
from players.entity import Player


@OnClientActive
def on_client_active(index):
"""Called when a player spawns into the server."""
player = Player(index)
print(index, player.steamid)

Re: Player connect event missing index?

Posted: Sat May 22, 2021 10:16 pm
by Zeus
This seems to work for me.

Syntax: Select all

@Event("player_activate")
def on_player_activate(event):
args = event.variables.as_dict()

index = index_from_userid(args['userid'])
player = Player(index)

assign_permissions(player)