Server:Packet.readUInt32 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. [4 bytes]

Syntax

int Packet.readUInt32()

Returns

  • number in range 0-4294967295;

Example

Server

const PLAYERS_AMOUNT_PACKET = 1002,

function sendPlayersAmount(id)
{
	local packet = Packet();
	packet.writeUInt16(PLAYERS_AMOUNT_PACKET);
	packet.writeUInt32(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.readUInt32));
		}
		break;
	}
}

addEventHandler("onPacket", onPacket);

Related functions