Server:Packet.send Server function

From Gothic 2 Online: Wiki
Jump to navigation Jump to search

This function was added in version: 0.0.3.0

Send packet to player.

Syntax

void Packet.send(int pid, int reliability)

Required Arguments

  • pid: The player id who receives packet.
  • reliability: The reliability of packet.

Example

Server

const MAX_PLAYERS_PACKET_ID = 1009;

addEventHandler("onPlayerJoin", function(pid)
{
	packet <- Packet();

	packet.writeUInt16(MAX_PLAYERS_PACKET_ID);
	packet.writeInt32(getMaxPlayers());

	packet.send(pid, RELIABLE_ORDERED);
});

Client

const MAX_PLAYERS_PACKET_ID = 1009;

addEventHandler("onPacket",function(packet)
{
	local id = packet.readUInt16();

	if (id == MAX_PLAYERS_PACKET_ID)
	{
		Chat.print(0, 255, 0, "Your id is: " + heroId + ". Max players: " + packet.readInt32());
	}
});

Related functions