network.getstats

Reads packet counters and transport diagnostics.

Syntax

Signature
network.getstats() -> table

Aliases

  • raknet.getstats
  • packets.getstats
  • RakNet.getstats

Parameters

This function takes no parameters.

Returns

TypeDescription
tableCurrent counters and last send error.

Notes

Fields are receivedPackets, sentPackets, receivedBytes, sentBytes, droppedReceived, droppedSent, editQueued, editOverflow, editExpired, editFailed, editSent, editCancelled, receiveHookDrops, and lastSendError. lastSendError is the last transport failure text.

Example

Luau
local Stats = network.getstats()
print("Sent:", Stats.sentPackets, "Received:", Stats.receivedPackets)
print("Dropped:", Stats.droppedSent, Stats.droppedReceived)

if Stats.lastSendError ~= "" then
    warn("Last transport error:", Stats.lastSendError)
end