network.getpacketlog

Reads recent packet history.

Syntax

Signature
network.getpacketlog(Limit: number?) -> {Packet}

Aliases

  • raknet.getpacketlog
  • packets.getpacketlog
  • RakNet.getpacketlog

Parameters

ParameterTypeDescription
Limitnumber?Maximum entry count. Defaults to 32 and is clamped from 0 through 4096.

Returns

TypeDescription
{Packet}One-based list of recent history entries.

Notes

Each entry includes sequence, timeMilliseconds, size, direction, dropped, and available packet content. Known packets also include id and type. Raw bytes are available through AsString, AsBuffer, and AsArray. Decoded fields are read through decoded, with decodeError explaining a parse failure.

Example

Luau
for _, Packet in network.getpacketlog(10) do
    print(Packet.sequence, Packet.direction, Packet.type, Packet.size)
    local Fields = Packet.decoded
    if Fields and Packet.type == "Chat" then
        print(Fields.username, Fields.text)
    elseif Packet.decodeError then
        warn(Packet.decodeError)
    end
end