protocol

Functions:

For PacketType, please use the full path like "Play.Client.CHAT".

on_receive

protocol.on_receive(packet_type: string, callback: function)

Name
Type
Description

packet_type

string

Packet type to listen to

callback

function

Callback function. The first parameter is the PacketWrapper object, and the second parameter is the Player object。

The return value of the callback: returning true means that the packet is allowed, The return of false or nil indicates that this packet is blocked.

Registers a callback function that is called when the server receives a packet of the specified type.

on_send

protocol.on_send(packet_type: string, callback: function)

Name
Type
Description

packet_type

string

Packet type to listen to

callback

function

Callback function. The first parameter is the PacketWrapper object, and the second parameter is the Player object。

The return value of the callback: returning true means that the packet is allowed, The return of false or nil indicates that this packet is blocked.

Registers a callback function that is called when the server sends a packet of the specified type.

send_packet

protocol.send_packet(player_name: string, packet: pktWrapper)

protocol.send_packet(player_name: string, packet_type: string, data: table)

Name
Type
Description

player_name

string

Player name

packet

pktWrapper

PacketWrapper object

packet_type

string

Packet type

data

table

Data of packet

Sends a packet to the specified player.

create_packet

protocol.create_packet(packet_type: string): pktWrapper

Name
Type
Description

packet_type

string

Packet type

Creates a new packet.

Methods:

🗳️ pktWrapper

PacketContainer's dynamic method forwarding, so you can use all the methods in PacketContainer.

Last updated