Having problems with Network

It worked, I added some more info to pass through the table and it just freaked out coming up with this error message:



Couldn't read type 189 Couldn't read type 209
[ERROR] lua/includes/modules/net.lua:92: table index is nil
  1. ReadTable - lua/includes/modules/net.lua:92
   2. ReceiveInfo - addons/darkrpmodification/lua/entities/censored/cl_init.lua:7
    3. unknown - addons/darkrpmodification/lua/entities/censored/cl_init.lua:23


This is my init function:



util.AddNetworkString( 'NET_EntityInfo' )

local sv_entity = {}
function sv_entity.SendInfo( Entity)
	local Tbl 			= {}
	Tbl.Counter 		= Entity.Counter
	Tbl.PBar 			= Entity.PBar

	net.Start( "NET_EntityInfo" )
		net.WriteEntity( Entity )
		net.WriteTable( Tbl )
	net.Broadcast()
end


and cl_init:




local cl_entity = {}
function cl_entity.ReceiveInfo()
	local Entity                         = net.ReadEntity()
	local Tbl 				= net.ReadTable()
	Printer.Counter 		= Tbl.Counter
	Printer.PBar 			= Tbl.PBar
end
net.Receive( 'NET_EntityInfo', cl_entity.ReceiveInfo() )


It worked, I added more stuff to pass through the Tbl and it freaked, then just commented them and no change, same error.

Try debugging it somehow.

Run PrintTable( Tbl ) before sending it and right after you receive it.

Here’s a tutorial which may help you. Something isn’t being written correctly. You do understand that you have to Read* in the order which you Write*, but something else is up.

You’d need to provide more code, such as the exact example of what is causing it. Chances are there is an issue with the table such as the entity not having a .Counter or PBar. Maybe do:

[lua] Tbl.Counter = Entity.Counter || 0;
Tbl.PBar = Entity.PBar || 0;[/lua]

So that something will be sent, if .Counter and .PBar do not exist on your entity. Then it will avoid the error, but that’s a hack-job. Where are you defining .Counter and .PBar? Are they being defined in the proper realm?

https://dl.dropboxusercontent.com/u/26074909/tutoring/networking/networking_booleans.lua

Thank you both, I fixed it, the problem was in the
net.Receive( ‘NET_EntityInfo’, cl_entity.ReceiveInfo() )
I added brackets by mistake
net.Receive( ‘NET_EntityInfo’, cl_entity.ReceiveInfo )
should be like that ^^.

Ah, yes. You must pass in the reference to the function and allow net.Receive to call it instead of executing the function and passing in the return if any.

If it’s solved, please click solved in the top left corner!