Garry's Mod Wiki

net.ReadTable

table net.ReadTable()

Description

Reads a table from the received net message.

Sometimes when sending a table through the net library, the order of the keys may be switched. So be cautious when comparing (See Example 1).
You must read information in same order as you write it.

See net.WriteTable for extra info. You may get net.ReadType: Couldn't read type X during the execution of the function, the problem is that you are sending objects that cannot be serialized/sent over the network.

Returns

1 table
Table recieved via the net message, or a blank table if no table could be read.

Example

This is an example of how the keys order may be switched:

--Client: function SendTable() local Table = {} Table.Type = "Dining" Table.Legs = 4 Table.Material = "Wood" net.Start("TableSend") net.WriteTable(Table) net.SendToServer() PrintTable(Table) -- Prints the order client side end --Server: function GotTable(len, Player) PrintTable(net.ReadTable()) -- Prints the order server side end net.Receive("TableSend", GotTable)
Output: Client:

Type = "Dining" Legs = 4 Material = "Wood"

Server:

Legs = 4 Material = "Wood" Type = "Dining"

Page Links


Special Pages


Wikis

?

Render Time: 34ms

DB GetPage 4
Generate Html 3
SaveChanges (1) 11
Render Body 0
Render Sidebar 13