GetPlayerPing

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search

getPlayerPing

Returns the current ENet round-trip latency measured for a connected player.

Syntax

int|false getPlayerPing(int playerId)

Parameters

Name Type Required Description
playerId int yes The connected player identifier.

Returns

Returns the current round-trip time in milliseconds, or false when the player is invalid or has no active peer.

Examples

Show a player's latency:

local ping = getPlayerPing(playerId)
if ping ~= false then
    outputChatBox("Ping: " .. ping .. " ms", playerId)
end

Notes

  • Available only in server-side resource scripts.
  • The value comes from ENet's measured peer round-trip time and is intended for diagnostics, rosters and gameplay-quality indicators.
  • Do not use one latency sample as proof of cheating; transient network jitter is normal.