Getting entities spawned on the server in the client

I spawn an entity on the server. I want to then tell the client what entity it is. This way, the client can have certain entities that it is aware of the angles and position of even though they were not spawned by the client. I tried sending the server-created entity to the client using the net library and the user message library. However, it only worked in singleplayer. The entity sent is a NULL entity when in multiplayer.
I’d have to guess that there is a different list of entities on the server and client when not playing singleplayer. I need to know how to translate an entity on the server to an entity on the client. I just want to know what entity on the server is what entity on the client.

They have the same EntIndex, however the client will not be aware of an entity that isn’t spawned in a certain radius near them, for optimization purposes. Once the client is aware of them the entities will be cached.

In the GMod 13 Beta, I printed out the models of all the entities in ents.GetAll() on both the server and the client on a listen server that was not set to singleplayer. The code worked as expected in singleplayer. I used the following code:

for k, v in pairs(ents.GetAll()) do local model = v:GetModel() if model then MsgN(v:EntIndex() .. " " .. model) end end

The entity I spawned (which I was able to recognize because it had a specific model that no other entities had) was #278 on the server and #5 on the client when using the lua_run console command and the lua_run_cl console command with the above code. The entity does not get sent properly in usermessages or the network library either, nor can I send the entity index and synchronize client to server using the entity index as a result of the difference of entity IDs from client to server.

I noticed that NWVars are broken on the clientside as well, as stated here. Is this a case of the GM13 Beta having a bug or am I able to work around this in order to get the entity from server to client. I guess I can use some hacky method that checks the most recent entity spawned with the correct model in order to synchronize the entity, but that might have collisions when two entities get spawned at nearly the same time.