rezecib Posted December 30, 2014 Share Posted December 30, 2014 (edited) 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 December 30, 2014 by rezecib Link to comment Share on other sites More sharing options...
DarkXero Posted December 30, 2014 Share Posted December 30, 2014 (edited) In playerspawner.lua, when a player rejoins a world, the event ms_newplayercharacterspawned gets pushed. Also maybe you can use the playeractivated event from player_common? Edited December 30, 2014 by DarkXero Link to comment Share on other sites More sharing options...
rezecib Posted December 30, 2014 Author Share Posted December 30, 2014 @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 More sharing options...
DarkXero Posted December 30, 2014 Share Posted December 30, 2014 @rezecib, how about the "entercharacterselect" event. Link to comment Share on other sites More sharing options...
rezecib Posted December 30, 2014 Author Share Posted December 30, 2014 @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 I'm starting to think that maybe such an event/hook doesn't exist. Link to comment Share on other sites More sharing options...
DarkXero Posted December 30, 2014 Share Posted December 30, 2014 (edited) @rezecib, "enterlimbo" ?"onsetprofile" ?"onsetplayerid" ? Edited December 30, 2014 by DarkXero Link to comment Share on other sites More sharing options...
rezecib Posted December 30, 2014 Author Share Posted December 30, 2014 @DarkXero,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 More sharing options...
Some1 Posted December 30, 2014 Share Posted December 30, 2014 (edited) @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 December 30, 2014 by Some1 Link to comment Share on other sites More sharing options...
rezecib Posted December 30, 2014 Author Share Posted December 30, 2014 @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 More sharing options...
Some1 Posted December 30, 2014 Share Posted December 30, 2014 (edited) @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 December 30, 2014 by Some1 Link to comment Share on other sites More sharing options...
rezecib Posted December 30, 2014 Author Share Posted December 30, 2014 @Some1, Not sure how to go about checking that (packet sniffing?). Userids seem to be working relatively well, though, so I'm just going to proceed with those for now. Link to comment Share on other sites More sharing options...
Some1 Posted December 30, 2014 Share Posted December 30, 2014 (edited) I think, you can chek it by spamming TheNet:GetClientTable() to raise (or to not) the net traffic activity. Edited December 30, 2014 by Some1 Link to comment Share on other sites More sharing options...
rezecib Posted December 30, 2014 Author Share Posted December 30, 2014 @Some1, Looks like it doesn't request it. There's something else in the C++ code that's updating it when it needs to be, I think. Link to comment Share on other sites More sharing options...
Some1 Posted December 31, 2014 Share Posted December 31, 2014 So it looks as though you can no longer doubt about overusing TheNet:GetClientTable() Link to comment Share on other sites More sharing options...
DarkXero Posted January 1, 2015 Share Posted January 1, 2015 @rezecib,Can this idea be changed and used somehow?net_change = net_bool(TheNet.GUID, "GetClientTable", "TableDirty") Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now