[Client] Main Packet Functions (LuaScript)

Category: LuaScript | Subcategory: Main Packet Functions


Main Packet Functions:

The LuaScript Packet provides a set of functions designed to facilitate packet communication between the Client and GameServer.
These functions allow Lua scripts to create, modify, and send custom packets, enabling dynamic server interaction and in-game data manipulation.
 

CreatePacket(packetName, packet)

  • Purpose: Creates a new packet to be sent to the GameServer.
  • Usage: Start by creating a packet before setting values.

SetDwordPacket(packetName, position)

  • Purpose: Sets a DWORD (32-bit) value at the specified position in the packet.
  • Usage: Useful for adding integer values.

GetDwordPacket(packetName, position)

  • Purpose: Retrieves a DWORD (32-bit) value from the specified position.
  • Usage: Read integer values from the received packet.

SetWordPacket(packetName, position)

  • Purpose: Sets a WORD (16-bit) value at a specific position.
  • Usage: Useful for smaller numeric values.

GetWordPacket(packetName, position)

  • Purpose: Gets a WORD (16-bit) value from the packet.
  • Usage: Retrieve small numeric values from packets.

SetBytePacket(packetName, position)

  • Purpose: Sets a BYTE (8-bit) value at the indicated position.
  • Usage: Insert flags or small data into the packet.

GetBytePacket(packetName, position)

  • Purpose: Gets a BYTE (8-bit) value from the packet.
  • Usage: Retrieve small flags or values.

SetCharPacket(packetName, string)

  • Purpose: Sets a string of up to 10 characters into the packet.
  • Usage: Insert player names, codes, or short identifiers.

GetCharPacket(packetName, position)

  • Purpose: Gets a string value from the packet starting at the given position.
  • Usage: Read back string data from the packet.

SetCharPacketLength(packetName, string, length)

  • Purpose: Sets a string into the packet with a specified length.
  • Usage: Insert longer text with a fixed size.

GetCharPacketLength(packetName, string, length)

  • Purpose: Retrieves a string of a given length from the packet.
  • Usage: Read longer text data.

SendPacket(packetName, aIndex)

  • Purpose: Sends the created packet to a specific player (aIndex).
  • Usage: Finalize and send the packet to the GameServer.

ClearPacket(packetName)

  • Purpose: Clears/reset the created packet data.
  • Usage: Always clear the packet after sending or before creating a new one to avoid data overlap.

Conclusion

The LuaScript Packet offers an essential set of functions to manage packet-based communication between the Client and GameServer in Lua.
By creating, editing, and sending packets efficiently, it empowers developers to implement complex server interactions, ensuring a seamless gaming experience.

Return