Valid Entity because NULL Entity from server to client ( net message )

Hi all,

So I have this net message(server):



local emeta = FindMetaTable("Entity")
function emeta:updateDoor()
	local data = doorData[self:EntIndex()] or {}
	print(self)
	net.Start("SIMSRP_DoorUpdate")
		net.WriteEntity(self)
		net.WriteTable( data )
	net.Broadcast()
end


Now the print returns: Vehicle [712][prop_vehicle_jeep]
This works fine and is valid. ( also the table works )

Now on the client the net.Receive function is:



net.Receive("SIMSRP_DoorUpdate", function()
	local ent = net.ReadEntity()
	local Table = net.ReadTable()

	print(ent)
	PrintTable(Table)
end)


Now the print on the client returns: [NULL Entity]
The table is received fine but only the entity is not working.

Any way to fix it?

Thanks,
Computer600

The client knows that the entity exists, right?

Keep in mind that all clients do not know about all entities inherently.

I believe that there’s a radius around a client within which all entities are networked to the player. Outside of this range and the client isn’t aware that the entities exist. This means that if the player is too far away from the door, even though it’s an actual entity the client will treat it as null.

In order to fix this, I would store a table of the doors ent indexes on the client. Whenever you want to interact with a door, reference its ent index in that table.

It’s not a radius, it’s visibility based and the existence of the entity is well known by the client, it is just not actively networked.

Both of you are right to an extent.

When I join my server, I use ent-indexes to network data. If I output the data ( two of those entities are custom elevators ) and I wasn’t close enough to those elevators, the client won’t know about them and it’ll output as NULL. As soon as I get close enough to the elevators, the client knows that it is a func_brush. Now, if I leave the area again, the client still knows that they are func_brushes…

Here’s the other thing, regarding PVS; clients come and go along with other entities like vehicles. The server stops broadcasting locations ( so if you ever see props floating that were parented to a vehicle, this is why and the coder didn’t create the logic for those instances; and used a method that is likely to break ). So a client on one side of the map can know that another client is on the server and that it is a valid entity, but may not know where that entity or client is outside of their PVS.

Sure, but the point still stands. Not all entities will be fully defined on the client at all times.

Once the entity is known though, the user doesn’t forget about it; positions / angles / etc… just stop getting networked outside of PVS.