Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

player.GetAll() out of sync on player and client #5320

Open galaxym4n opened 2 years ago

galaxym4n commented 2 years ago

Details

Tell us exactly what happens here, every single detail that you can think of. Please include information such as which Beta Branch your game is on, the console log (opened in-game by pressing SHIFT+ESC) and the version of the game you are running, which can be retrieved via the version console command. Please try running a different(dev)/none beta branch and verifying your game cache integrity before reporting an issue.

If you are going to post crash dumps (.mdmp or .dmp files), please either send them to robotboy655@facepunchstudios.com or create a permanent link.

Steps to reproduce

Tell us how to reproduce the problem here, step by step. If it is a modding API issue, please include minimal code to reproduce the issue on demand.

player.GetAll() is not "synced" correctly between server and client ( Like for example it says 11 on server and 4 on client, the server is always correct but client is always lower )

CLIENT: https://cdn.discordapp.com/attachments/567617926991970306/1015778173268541491/unknown.png SERVER: https://cdn.discordapp.com/attachments/567617926991970306/1015778214376919110/unknown.png

Was told to report this after talking to a few other developers as they dont see why it was happening.

CornerPin commented 2 years ago

The missing entities are outside of the client's PVS, this is a Source Engine optimization technique that doesn't network some entities to the clients if they can't possibly be seen. The missing entities weren't networked and were never created on the client side, hence player.GetAll doesn't return them.

galaxym4n commented 2 years ago

The missing entities are outside of the client's PVS, this is a Source Engine optimization technique that doesn't network some entities to the clients if they can't possibly be seen. The missing entities weren't networked and were never created on the client side, hence player.GetAll doesn't return them.

Yeah,optimisation or not the problem with this is that it messes with things like scoreboards so it needs fixing...

bigdogmat commented 2 years ago

The missing entities are outside of the client's PVS, this is a Source Engine optimization technique that doesn't network some entities to the clients if they can't possibly be seen. The missing entities weren't networked and were never created on the client side, hence player.GetAll doesn't return them.

Players always exist no matter what, their network vars might not sync as fast but they will exist.

neico commented 2 years ago

I wonder if player.GetCount() shows the correct amount, then you could probably bypass it via Entity() and the like for the scoreboard iteration part It's probably also worth looking at team.GetPlayers() to see if it works around the PVS optimization.

There's also a userinfo network stringtable that could be used for a primitive lookup, if access to those were exposed in lua That actually could be pathway to make the function reliable on the client, in fact that's what the default HL2MP Scoreboard makes use of.

robotboy655 commented 2 years ago

You are all speculating without seeing OP's code or any reproducible code or setup presented.

galaxym4n commented 2 years ago

Client: print("how many in table?") print(#player.GetAll()) print("--------------") for k, v in pairs( player.GetAll() ) do print(k) print("-----------") print(v) end

Server: print("how many in table?") print(#player.GetAll())

that’s literally all i’m running

phoen1xf commented 2 years ago

Players aren't necessarily available the moment you join the server (for up to 10 seconds you'll only be told about players in your pvs/area) and create the element, if you're doing that on startup. It looks that way to me anyway. Otherwise I'd try changing the map to a different one and see if the issue persists because it's not something I've ever seen before. You'll want to look at how other scoreboards like TTT do it, where they check/add and remove rows

galaxym4n commented 2 years ago

I've always used player.GetAll() to make scoreboards and such and never had this issue before though, has GarrysMod changed something with PVS or anything similar recently which has caused this?

phoen1xf commented 2 years ago

no

galaxym4n commented 2 years ago

Then it doesn't explain what has happened to base/sandbox/darkrp gamemodes that has caused this issue to occur all of a sudden, and i highly doubt darkrp has caused it

phoen1xf commented 2 years ago

garrysmod has not been updated in a while, there is no magical "update that broke it" my gamemode is based from sandbox and does not suffer from this issue