Registers an active hook on outgoing packets. The callback receives a packet object, and may call packet:SetData(...) to replace the payload or packet:Block() to drop the packet entirely.
RakNet is off by default. The library exists only when the RakNet feature is enabled in the Athena loader, and it is published on getgenv() rather than as a plain global. Guard your code with if getgenv().raknet then ... end, or read raknet.is_enabled.

Parameters

function
required
Called as callback(packet) before each packet is sent.

Behavior

  • SetData and Block work only here. They are valid while a send hook is running and raise otherwise.
  • Blocking stops the chain. Once a hook blocks a packet, later hooks are not called for it.
  • A replacement payload must fit the capture limit, otherwise SetData raises.
  • Errors are contained: a raising hook is logged and the packet proceeds.

Example

Errors