Player connect event missing index?

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Zeus
Member
Posts: 52
Joined: Sat Mar 24, 2018 5:25 pm
Location: Chicago
Contact:

Player connect event missing index?

Postby Zeus » Sat May 22, 2021 9:27 pm

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?
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: Player connect event missing index?

Postby VinciT » Sat May 22, 2021 9:45 pm

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)
ImageImageImageImageImage
User avatar
Zeus
Member
Posts: 52
Joined: Sat Mar 24, 2018 5:25 pm
Location: Chicago
Contact:

Re: Player connect event missing index?

Postby Zeus » Sat May 22, 2021 10:16 pm

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)
Last edited by L'In20Cible on Sun May 23, 2021 3:08 am, edited 1 time in total.
Reason: [code] → [python]

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 27 guests