Skip to content

Packet Handlers

Intercept and inspect incoming and outgoing packets.

Important

Blocking essential packets can cause disconnections. Test thoroughly before production use.

Callbacks

on_packet_recv(packet: in_packet) -> boolean

Called when receiving packets from the server. Return true to allow, false to block.

on_packet_send(packet: out_packet) -> boolean

Called when sending packets to the server. Return true to allow, false to block.

Plugin Required

Must be part of a plugin with proper metadata structure.

Packet Methods

packet:get_opcode() -> number

Returns the packet opcode.

packet:decode_1() -> number

Reads 1 byte (0-255).

packet:decode_2() -> number

Reads 2 bytes (0-65535).

packet:decode_4() -> number

Reads 4 bytes (0-4294967295).

packet:decode_8() -> number

Reads 8 bytes.

packet:decode_string() -> string

Reads a string.

INFO

Decode methods read sequentially. Each call advances the read position.

Example

lua
plugin = {
    name = "Packet Logger",
    author = "YourName",
    version = "1.0",
    description = "Logs packet opcodes",
    load = true
}

function on_packet_recv(packet)
    local opcode = packet:get_opcode()
    core.log(string.format("[IN]  0x%04X", opcode))
    return true
end

function on_packet_send(packet)
    local opcode = packet:get_opcode()
    core.log(string.format("[OUT] 0x%04X", opcode))
    return true
end