Server:Packet.readUInt8 Server function

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

This function was added in version: 0.0.3.0

Get number from packet. (1 byte)

Syntax

int Packet.readUInt8()

Returns

  • number in range 0-255;

Example

Server

const PLAYERS_AMOUNT_PACKET = 1002,

function sendPlayersAmount(id)
{
	local packet = Packet();
	packet.writeUInt16(PLAYERS_AMOUNT_PACKET);
	packet.writeUInt8(getPlayersCount());
	packet.send(id);
}

Client

const PLAYERS_AMOUNT_PACKET = 1002,

local function onPacket(packet)
{
	switch(packet.readUInt16())
	{
		case PLAYERS_AMOUNT_PACKET:
		{
			chat.newMessage(format("Players in game: %d", packet.readUInt8));
		}
		break;
	}
}

addEventHandler("onPacket", onPacket);

Related functions