RakNet

RakNetPacket.SetData

Replaces the data stored on a live RakNetPacket with a string, buffer, or array table of byte numbers.

ไวยากรณ์

RakNetPacket.SetData(packet: RakNetPacket, data: string | buffer | {number})

Arguments

ชื่อชนิดคำอธิบาย
packetRakNetPacketLive packet object passed to a RakNet hook or signal callback.
datastring | buffer | {number}Replacement packet data. Array-table bytes must be numbers from 0 through 255.

คำอธิบาย

Replaces the data stored on a live RakNetPacket with a string, buffer, or array table of byte numbers. The packet id field is updated from the first byte, or 0 when the new data is empty. The method returns no values.

เรียกด้วย parameter 2 ค่า: packet, data ตาราง arguments อธิบายค่าที่จำเป็นและค่าที่ปรับพฤติกรรม

ไม่ส่งคืนข้อมูล ให้มอง call นี้เป็น action และจัดการ error รอบจุดที่เรียกเมื่อจำเป็น

ตัวอย่าง

Replace packet data from inside a live packet callback.

if RakNet.is_enabled then
    RakNet.OnPacketSend:Connect(function(packet)
        packet:SetData({ 0x83, 0x00 })
    end)
end

Types

RakNetPacket

Live packet object passed to RakNet hooks and packet signal callbacks. It is only valid during the callback that receives it.

SetData (data: string | buffer | {number}) -> () Replaces packet bytes and updates the packet id from the first byte, or 0 for empty data.Block () -> () Marks the packet as blocked.Ignore () -> () Alias that resolves to Block.AsString string Packet bytes as a Lua string.AsArray {number} Packet bytes as a 1-based array of numbers.AsBuffer buffer Packet bytes as a buffer.Data buffer Packet bytes as a buffer.ID number Packet id value. PacketId, PacketID, and Id resolve to the same value.Priority number Packet priority value.Reliability number Packet reliability value.OrderingChannel number Packet ordering channel value.SystemIdentifier string Packet system identifier as decimal string.Broadcast boolean Packet broadcast flag.ForceReceiptNumber number Packet receipt number.Size number Number of bytes in the packet data.