Skip to content

feat(net): add client-side ping, variance and packet loss natives#3911

Open
YgorLeal wants to merge 1 commit intocitizenfx:masterfrom
YgorLeal:feat/client-ping-loss-natives
Open

feat(net): add client-side ping, variance and packet loss natives#3911
YgorLeal wants to merge 1 commit intocitizenfx:masterfrom
YgorLeal:feat/client-ping-loss-natives

Conversation

@YgorLeal
Copy link
Copy Markdown

@YgorLeal YgorLeal commented Apr 9, 2026

Summary

  • Adds three new client-side natives: GET_CLIENT_PING, GET_CLIENT_PING_VARIANCE, and GET_CLIENT_PACKET_LOSS
  • These values were already available internally via the ENet peer but not exposed to the scripting layer
  • Adds GetPacketLoss() to the NetLibrary interface, following the same pattern as GetPing() and GetVariance()

Usage

local ping = GetClientPing()             -- RTT in ms, -1 if not connected
local variance = GetClientPingVariance() -- RTT variance in ms, -1 if not connected
local loss = GetClientPacketLoss()       -- packet loss percentage, -1 if not connected

Test plan

  • Connect to a server and verify GetClientPing() returns a valid RTT in ms
  • Verify GetClientPingVariance() returns RTT variance matching netgraph 1 display
  • Verify GetClientPacketLoss() returns packet loss percentage matching cl_drawPacketLoss
  • Verify all three return -1 when not connected to any server

Fixes #2233

…ting

Add three new client-side natives: GET_CLIENT_PING, GET_CLIENT_PING_VARIANCE,
and GET_CLIENT_PACKET_LOSS. These values were already available internally
via the ENet peer but not exposed to the scripting layer.

Also adds GetPacketLoss() to the NetLibrary interface, following the same
pattern as the existing GetPing() and GetVariance() methods.

Fixes citizenfx#2233
@github-actions github-actions Bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid Requires changes before it's considered valid and can be (re)triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetPlayerPing and GetPlayerLoss for the client

1 participant