network.create
Creates a packet from its schema.
Syntax
Signature
network.create(Type: number | string, Fields: table?) -> PacketAliases
raknet.createpackets.createRakNet.create
Parameters
| Parameter | Type | Description |
|---|---|---|
Type | number | string | Packet ID from 0 through 63, or exact type name from network.gettypes(). |
Fields | table? | Decoded fields to merge into the codec defaults. |
Returns
| Type | Description |
|---|---|
Packet | New packet object. |
Notes
Fields optionally overrides those defaults using a JSON merge patch. Returns a mutable packet object. Unknown IDs, unsupported schemas, and invalid fields raise errors.
Example
Luau
local Packet = network.create("Chat", {
sender_id = "0",
username = "Example",
text = "Hello",
})
print(Packet.type, Packet.PacketId, Packet.Size)
print(Packet.decoded.text)
-- Creating a packet does not send it.