Revision Difference
net.ReadTable#518703
<function name="ReadTable" parent="net" type="libraryfunc">
<description>
Reads a table from the received net message.
<note>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).</note>
<warning>You **must** read information in same order as you write it.</warning>
See <page>net.WriteTable</page> for extra info.
You may get <pre class="inline">net.ReadType: Couldn't read type X</pre> during the execution of the function, the problem is that you are sending objects that cannot be serialized/sent over the network.
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.
</description>
<realm>Shared</realm>
<file line="115">lua/includes/extensions/net.lua</file>
<rets>
<ret name="" type="table">Table recieved via the net message, or a blank table if no table could be read.</ret>
</rets>
</function>
<example>
<description>This is an example of how the keys order may be switched:</description>
<code>
--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)
</code>
<output>
Client:
```
Type = "Dining"
Legs = 4
Material = "Wood"
```
Server:
```
Legs = 4
Material = "Wood"
Type = "Dining"
```
⤶
<nowiki /><!-- without this the code tag breaks apart for some BS reason -->⤶
</output>⤶
⤶
</output>⤶
</example>