Out Packet
Create and send custom packets to the server.
Important
Sending invalid or malformed packets can cause disconnection. Only use if you understand the packet structure.
Example Disclaimer
Examples use placeholder opcodes for demonstration only. Research actual packet structures for your game version.
Constructor
out_packet(opcode: number) -> OutPacket
Creates a new packet with the specified opcode.
local packet = out_packet(0x100)Encoding Methods
All methods return the packet object for method chaining.
packet:encode_1(value: number) -> OutPacket
Encodes 1 byte (0-255).
packet:encode_2(value: number) -> OutPacket
Encodes 2 bytes (0-65535).
packet:encode_4(value: number) -> OutPacket
Encodes 4 bytes (0-4294967295).
packet:encode_8(value: number) -> OutPacket
Encodes 8 bytes.
packet:encode_string(text: string) -> OutPacket
Encodes a string.
packet:encode_buffer(data: string | buffer) -> OutPacket
Encodes raw binary data. Accepts either a Lua string or a native Luau buffer — use the buffer form to forward bytes from in_packet:decode_buffer without a string round-trip.
-- from a string
out_packet(0x100):encode_buffer("\x01\x02\x03"):send()
-- from a buffer (e.g. forwarded from on_packet_recv)
local buf = incoming:decode_buffer(32)
out_packet(0x100):encode_buffer(buf):send()Utility Methods
packet:to_string() -> string
Returns hexadecimal representation of packet contents.
packet:get_opcode() -> number
Returns the packet opcode.
packet:get_data() -> string
Returns hexadecimal representation of packet contents (alias of to_string()).
packet:send()
Sends the packet to the server.
Examples
Basic Usage
-- Create and send packet
local packet = out_packet(0x100) -- Use real opcode
packet:encode_1(5)
packet:encode_2(1000)
packet:send()Method Chaining
out_packet(0x200)
:encode_1(10)
:encode_2(500)
:encode_4(100000)
:encode_string("Hello")
:send()