Jump to content

Recommended Posts

In playerstatusscreen.lua, there is code for the host and client performance

TheNet:GetClientTable()

TheNet:GetClientTable() returns a ordered list of client data

These ones seem to be used by this klei code, I didn't do a data dump of the function to see if there is other data.

  • userid
  • colour
  • prefab
  • userflags
  • base_skin
  • playerage
  • performance (for host)
  • netscore (for clients)

I have no idea for sure if this is the correct code, buts its a start to hunt down the solution.

Edited by IronHunter
  • Thanks 1

The green/yellow/red bar for players is determined by their netscore.
If I remember correctly, 0 is green, 1 is yellow, 2 is red.

If you want their actual ping, that can be retrieved on the client-side with TheNet:GetPing() or TheNet:GetAveragePing(). I'm not sure what it uses for the average.

Edited by penguin0616
  • Thanks 1
9 hours ago, penguin0616 said:

The green/yellow/red bar for players is determined by their netscore.
If I remember correctly, 0 is green, 1 is yellow, 2 is red.

Is there a code for it for this netscore thing? Like  TheNet:GetClientNetScore() or something then it can be used in functions and stuff?

1 hour ago, . . . said:

Is there a code for it for this netscore thing? Like  TheNet:GetClientNetScore() or something then it can be used in functions and stuff?

TheNet:GetClientTableForUser(klei_id) returns the table of information that IronHunter outlined.

14 hours ago, IronHunter said:
  • userid
  • colour
  • prefab
  • userflags
  • base_skin
  • playerage
  • performance (for host)
  • netscore (for clients)

That is how you can get the netscore.

2 hours ago, penguin0616 said:

TheNet:GetClientTableForUser(klei_id) returns the table of information that IronHunter outlined.

Would it be used like this?

local function Something(inst)
	local player = TheNet:GetClientTableForUser(inst)
	if player.netscore >= 2 then	
		print("lag")
	end
end

or it's just much more complicated, if it is then nvm 

16 minutes ago, . . . said:

Would it be used like this?


local function Something(inst)
	local player = TheNet:GetClientTableForUser(inst)
	if player.netscore >= 2 then	
		print("lag")
	end
end

or it's just much more complicated, if it is then nvm 

If you're doing it like that, then you'd also want to check if player isn't nil.

And the input for TheNet:GetClientTableForUser is a userid.  Assuming you're passing a player entity into it, then get its userid via `inst.userid`.

If whatever you're doing needs a higher precision of the latency, then have the client send in its average ping or a current timestamp with the mod RPC call to the server to let it do some math and compensate for whatever it is you're trying to compensate.

 

14 hours ago, penguin0616 said:

If you want their actual ping, that can be retrieved on the client-side with TheNet:GetPing() or TheNet:GetAveragePing(). I'm not sure what it uses for the average.

Game uses RakNet for its network handling, and it has an API call that uses the same syntax.

Briefly reading over the code bits it looks like an average of the last 5 ping responses.

https://github.com/facebookarchive/RakNet/blob/master/Source/RakPeerInterface.h#L334

https://github.com/facebookarchive/RakNet/blob/master/Source/RakPeer.cpp#L2142

https://github.com/facebookarchive/RakNet/blob/master/Source/RakNetTypes.h#L462

Edited by CarlZalph
  • Thanks 2

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...