network.block

Blocks a packet type.

Syntax

Signature
network.block(Id: number, Direction: string?) -> boolean

Aliases

  • raknet.block
  • packets.block
  • RakNet.block

Parameters

ParameterTypeDescription
IdnumberInteger packet ID from 0 through 63.
Directionstring?Packet direction. Defaults to outgoing.

Returns

TypeDescription
booleanWhether the blocking setting was accepted.

Notes

Direction defaults to outgoing. Incoming aliases are incoming, receive, and received. Outgoing aliases are outgoing, send, and sent.

Example

Luau
local Direction = "outgoing"
local PacketId = 2 -- Chat
local WasBlocked = network.isblocked(PacketId, Direction)

if network.block(PacketId, Direction) then
    print("Outgoing chat is blocked for five seconds")
    task.delay(5, function()
        if not WasBlocked then
            network.unblock(PacketId, Direction)
        end
    end)
end