[DiscordArchive] When the server sends a packet to the client and I use Eluna's WorldPacket method, how can I retriev
[DiscordArchive] When the server sends a packet to the client and I use Eluna's WorldPacket method, how can I retriev
Archived author: mateo • Posted: 2023-11-29T15:29:19.325000+00:00
Original source
When the server sends a packet to the client and I use Eluna's WorldPacket method, how can I retrieve the data inside?
Archived author: mateo • Posted: 2023-11-29T15:29:54.803000+00:00
Original source
```lua
local function HandlePacket(event, packet, player)
local opcode = packet:GetOpcode()
local size = packet:GetSize()
local data = packet:GetData()
print("Received packet - opcode: " .. opcode .. ", size: " .. size)
local playerName = packet:ReadString()
local playerLevel = packet:ReadUInt8()
local playerHealth = packet:ReadFloat()
--Can we obtain a structure?
local customData = packet:ReadStruct(MyCustomStruct)
local responsePacket = WorldPacket(CUSTOM_OPCODE)
responsePacket:WriteString("Hello, " .. playerName)
player:SendPacket(responsePacket)
end
RegisterPacketEvent(0x019F, 7, HandlePacket)
```