Get player id in server

Yeah, not optimal enough.

Yeah… I understand. I’m not sure why it doesn’t exist, though. That little client script may not be as good as just having an event, but it’s the best it will get for what you need really.

Only thing i can think of is that it’s just not available yet, until the server is absolutely sure that the player has successfully joined. No need in giving out server ID’s if the player ends up disconnecting before they even properly joined.

What are you intending to use the player ID for? You can’t send events to players before they have loaded fully and started executing client scripts, your script may restart (which if handling connections only would make your server script completely unaware of the player) at the least during development, and all read-only data you might want before a player can interact with the game (except linking it to an existing NetID, which has practically no use) can be obtained from the TempID in playerConnecting.

If you want to handle the process before a player becomes fully interactive, simply don’t spawn the player (i.e. calling spawnmanager callbacks) until a server script gives an A-OK from an event triggered at resource start time.

If all you want is the proper source/server id of the player as soon as they’re “fully joined”, just add this in a client.lua script:


Doesn’t matter which resource you put it in, it’s definitely not an “overkill” solution. You can still listen for it from a c# resource and it’s just 3 lines of code.


That’s actually what I’m trying to solve for…I want my restarted script to become re-acquainted with all of the players that are currently active on the server. I have an onjoin and on-leave event, but I want to make sure that if anything happens to this resource specifically, I can restart with little downtime. Do you think there’s an option for this yet?


Isolate player information into a separate resource, recode your resource to link IDs in the separate script to player identifiers whenever it boots up.