Jump to content

Events or hooks for when TheNet's client table changes?

Recommended Posts

So I've been looking into getting global player indicators working, and one thing that would be nice would be if I could store the client table index for a given global position (the reason this is nice is because it prevents me from writing networking to send over information that's already available, namely the userflags, prefab, and player name). This works as long as the client table doesn't change, but when a player joins or leaves, the client table indexes shift.


So my question is if there's an event that gets pushed when a client connects. Things I'm already aware of, but don't seem adequate right now:


  • ms_playerjoined event -- this gets triggered in player_common, as the prefab is being made, which means it only occurs after the player has selected a character. The client table changes earlier, when they first reach character select.
  • ms_playerspawn event -- similar, just gets pushed a little sooner (ms_playerjoined is put into a DoTaskInTime, although that line is called sooner)
  • ms_newplayercharacterspawned event -- gets triggered after someone picks a character. Unfortunately, the client table changes before that.
  • playeractivated event -- pushed during the spawning of the player, so still too late. For other applications, this is useful because it's pushed after the HUD has been attached to the player.
  • entercharacterselect event -- pushed locally instead of on the server, and still ends up being later than the client table gets updated.
  • ms_playerleft event -- this seems to work well enough for players leaving changing the client table, but it still leaves open how to handle it as they join


Edit: I've decided to sync the userid (which only needs to happen once), then have clients individually check the client table to find the entry with the matching userid. This approach seems to be working well.

Edited by rezecib
Link to comment
Share on other sites

@DarkXero, Unfortunately anything from player_common won't be run until they pick a character. What I'm trying to capture is the event of them joining the server initially (if you keep the scoreboard up as someone's joining, you'll see an "unknown" character pop up for them while they're on the select-- the scoreboard references TheNet:GetClientTable(), which I'd like to avoid checking on every update if possible).


For now what I'm doing is attaching the userid, then having each client scan the client table for the userid to get the character data, but it seems like there ought to be a better solution...

Link to comment
Share on other sites


enterlimbo is part of entityscript, so can't occur until there's an associated entity...

onsetprofile is in the same boat...

onsetplayerid I can't figure out what it does, but it's a "screenevent" that triggers for the main screen under certain conditions that I haven't determined...


Thank you for digging so deep to find an answer, though!

Link to comment
Share on other sites

@DarkXero, Can't believe I missed that one! But hmm, I just tested and it's triggered locally, and still ends up being up to a few seconds after the client table has changed :(


But why do you need to catch it quicker than few seconds?


Edited by Some1
Link to comment
Share on other sites

@Some1, If you have the global player arrows up, it'll be grabbing userflags and portrait data and such from the client table. If the client-table changes while they're up, it will misalign and cause about half of the player arrows to be pointing to the wrong player.


Right now I'm syncing userids instead so I can check by that. I'm guessing all of the initial connection networking is handled by the C++ code (which is where the ClientTable is coming from anyway), so that might be why there's no good hook/event available for this.

Link to comment
Share on other sites

@rezecib, did you check if TheNet:GetClientTable() cause the game to send net packets or not?

It's possible, that TheNet:GetClientTable() just copies some data from inner c++ game code, wich updates by the other ways...

Edited by Some1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...