Server:Packet.writeString Server function

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

This function was added in version: 0.0.3.0

Insert string value to packet.

Syntax

void Packet.writeString(string value)

Required Arguments

  • value: string value. Max length is 101.

Example

Server

const SERVER_WORLD_PACKET_ID = 1005;

addEventHandler("onPlayerCommand",function(pid, cmd, params)
{
	if (cmd == "server-world")
	{
		packet <- Packet();
		
			packet.writeUInt16(SERVER_WORLD_PACKET_ID);
			packet.writeString(getServerWorld());
		
		packet.send(pid, RELIABLE_ORDERED);
	}
});

Client

const SERVER_WORLD_PACKET_ID = 1005;

addEventHandler("onPacket",function(packet)
{
	local id = packet.readUInt16();
	
	if (id == SERVER_WORLD_PACKET_ID)
	{
		Chat.print(255, 255, 255, "Server world is: " + packet.readString());
	}
});

Related functions