RakNet
Packet callbacks, packet data, and connection methods.
Functions
raknet.add_receive_hookRegister a persistent callback for incoming packets. It is useful for observing an identified packet type or changing a packet before the game receives it.
raknet.add_send_hookRegister a persistent callback for outgoing packets. Use it for brief inspection or for a specific, intentional packet edit before the packet is sent.
raknet.is_enabledCheck whether RakNet packet access is ready for the current game generation. Call it before registering observers or submitting a packet.
raknet.OnPacketReceive:ConnectConnect a listener to incoming packet events. Keep the returned connection if the observer should be removed when a panel or task closes.
raknet.OnPacketReceive:OnceObserve just the next incoming packet. The one-shot connection unregisters before the callback, so the callback cannot accidentally receive a second packet.
raknet.OnPacketReceive:WaitYield until the next incoming packet and receive a copied snapshot. This is useful when a coroutine needs one packet’s data after its event callback has finished.
raknet.OnPacketSend:ConnectConnect a listener to outgoing packet events. It returns a connection object, which is convenient when an observer should live for a specific task or time window.
raknet.OnPacketSend:OnceListen for the next outgoing packet and disconnect automatically before your callback runs. Use it for a one-packet observation without a manual cleanup path.
raknet.OnPacketSend:WaitWait for the next outgoing packet without writing a persistent callback. Unlike a callback’s live view, the returned snapshot remains usable after the wait completes.
raknet.receiveSubmit an incoming packet to the game from protocol-valid data. Use it only when the receiving side is expected to understand the payload; the packet passes through incoming observers.
raknet.remove_receive_hookUnregister a callback previously added with raknet.add_receive_hook. Use this when an inspection window or packet modification is finished.
raknet.remove_send_hookUnregister a callback previously added with raknet.add_send_hook. Keep the exact function reference you registered so cleanup can remove it later.
raknet.sendSubmit an outgoing RakNet packet using data you already know is valid for the game’s protocol. Manual sends pass through your outgoing packet callbacks before entering the native queue.
RakNetConnection:DisconnectStop a packet signal connection from receiving future events. Use it to clean up a Connect or Once observer when its work is finished.
RakNetPacket:BlockVeto the current packet before it reaches its destination. Use it with a narrow, verified condition; later observers can still inspect the view but cannot undo the block.
RakNetPacket:SetDataReplace the bytes in the current packet view before it continues through observers and transport. Use it when you know the exact encoded packet format and need a deliberate rewrite.