Sending world entity data to client

I’m creating a system to create properties for DarkRP in game.
I save the doors to the file as Entity:MapCreationID() and load them back as entities with ents.GetMapCreatedEntity().

So I have the table of doors on the server and send it to the client, but due to this
(At this point the client only knows about the entities that are within the spawnpoints’ PVS) the server sends an entity that is not within the PVS, the client will receive it as NULL entity.
The client only receives the entities at PVS, the rest are null.

So, how can I sync the entities to the client so that the client will have them all in a table?
Would I have to just keep checking if each entity is in the client’s PVS and send them individually as loaded, if so is there an easy way of doing it?

I’m creating a system to create properties for DarkRP in game.
I save the doors to the file as Entity:MapCreationID() and load them back as entities with ents.GetMapCreatedEntity().

So I have the table of doors on the server and send it to the client, but due to this
(At this point the client only knows about the entities that are within the spawnpoints’ PVS) the server sends an entity that is not within the PVS, the client will receive it as NULL entity.
The client only receives the entities at PVS, the rest are null.

So, how can I sync the entities to the client so that the client will have them all in a table?
Would I have to just keep checking if each entity is in the client’s PVS and send them individually as loaded, if so is there an easy way of doing it?

Fixed it up for ya :slight_smile:

Thanks :slight_smile:

I would recommend keeping them in a table with all the data and sending the table to the client. Let the client interpret the data when it’s appropriate

Example (Serverside):



GAMEMODE.PropertyTable = {}
--Populate the propertytable with a format of GAMEMODE.PropertyTable[ CreationID ] = DATA
net.Start( "netmessagename" )
net.WriteTable( GAMEMODE.PropertyTable )
net.Send( playerentity ) / net.Broadcast()


This is a rough example, obviously syntax is important here. I’m guessing you will be using a property NPC or something to sell it. You can loop through that table on the client’s end and just use the data to create the stuff. The clientside code of this is entirely up to you. I’m not sure what you’re doing with this data

If you mean send the MapCreationId’s instead of the entities then I’ve tried that.
ents.GetMapCreatedEntity is on server only, unless it was only not working because the entity was nil due to the PVS, in which case how would i only convert to entity when it will be in pvs?

Yeah those are both serverside functions so networking is a must, but what exactly are you going to be doing with it? You can always add EntIndex interpretations within the data you are sending to the client

The client needs the doors for rendering nice visuals of the property boxes.

Do you mean send the Entity:EntIndex() to the client instead of the MapCreationId then do ents.GetByIndex on the client to check if its valid/use it?

That is already what net.WriteEntity and net.ReadEntity do. But you could send the entindex manually and store the entindex and check later.

Ok I’ve got a working system, thanks.
Its incredibly hacky feeling, I have to make any client functions that send updates about doors to check if any of the doors aren’t loaded already and then error ect, but i think i have solutions for all the problems.

Would be very nice if there was a function to force load a entity, or even it auto loads entities received from net.ReadEntity()