Data Tables Help

So I’m working on an entity that when spawned, every player in the server draws a bunch of information on that entity. I have been using SetNWInt which works just fine, but it can create performance issues as it is not very optimized (the client pings the server every millisecond for the info instead of whenever it is changed). The solution is to use Data Tables, but when I set them up, the client can not find the variable, it only transmits across the server.

Here’s where I set them up in my Init.lua file.


function ENT:SetupDataTables()
	self:NetworkVar("String",0,"EntityType")
	self:NetworkVar("String",1,"WPName")

	self:NetworkVar("Int",0,"WPCircle")
	self:NetworkVar("Int",1,"WPTriangle")
	self:NetworkVar("Int",2,"WPDistance")

	self:NetworkVar("Vector",0,"WPColor")
	self:NetworkVar("Int",3,"WPAlpha")
end

And here’s an instance where I ask for one of the variables on the client (cl_init.lua).


local wpname = e:GetWPName()

draw.DrawText(wpname,"wpfont",pos2d.x,pos2d.y + 13 + yOffset,Color(color,a),TEXT_ALIGN_CENTER)

    When running this code I get an error - 

Now when getting the variables from the server’s side it works just fine, which means that it should be setting up the table correctly, but the client side just can’t do it.

Any help would be appreciated :slight_smile:

SetupDataTables should be shared.

Oh my God thank you it worked :), been trying to fix this for so long can’t believe that never occurred to me.