Sending game packets

The GameUpdatePacket Lua table is used to structure data for sending raw packets in the game. Here is an explanation of each member of this table:

  • type: An integer that specifies the type of the game update packet.

  • pos_x: An integer representing the X-coordinate position.

  • pos_y: An integer representing the Y-coordinate position.

  • int_x: An integer value for an internal X-coordinate, often used for different scales or calculations.

  • int_y: An integer value for an internal Y-coordinate, similarly used for separate computations.

  • netid: An integer serving as the network identifier for the entity associated with this packet.

  • flags: An integer flag used to specify various status indicators or options for the packet.

  • int_data: An integer representing additional data required for the packet's context.

To create a valid game update packet in Lua, populate the GameUpdatePacket table with appropriate values, like type, position coordinates, network identifiers, etc., and use SendPacketRaw(gamepacket) to send it. The example below demonstrates how to send a packet using these parameters.

local gamepacket = GameUpdatePacket()
gamepacket.type = 0  -- Specifies the packet type
gamepacket.pos_x = GetLocal().pos.x * 32  -- X-coordinate position
gamepacket.pos_y = GetLocal().pos.y * 32  -- Y-coordinate position
gamepacket.flags = 65584  -- Status flags
gamepacket.netid = GetLocal().netid  -- Network ID
SendPacketRaw(gamepacket)  -- Sends the packet

This script sends a "Player touched cactus state" packet with specific values in its structure.

Last updated