Problem with usermessages

I want to send a var from the server to the client. Here’s what I got


function ENT:SyncItem()
	print("RP_WorldItemSync, Server side")
	local rp = RecipientFilter()
	umsg.Start("RP_WorldItemSync", rp)
		umsg.Entity( self.Entity )
		umsg.String( self.Entity.ID )


usermessage.Hook("RP_WorldItemSync", function( um )
	item = um:ReadEntity()
	id = um:ReadString()
	item.ID = id
end )

On the server side print(tostring(self.Entity)) outputs a valid entity which I suppose means it’s sending it correctly. But when the message gets to the client the entity is NULL.

I’ve been at this for a while now, anyone know why?

EDIT: The id arrives properly with the right value. So it’s not the um as a whole failing, just the entity bit.

I would suggest using the entid and send it, and then get on the client the ent matching the ID

I don’t know if Garry completely removed the .Entity thing off the ENT tables, but you shouldn’t use it in any case. It’s redundant.

Just use “self”.

I don’t think he removed it, since it would break a ton of addons.

It still works, but it’s deprecated.

I have already worked this out.

The umsg was sent right after spawn() was called. When the umsg got to the client, the entity was not yet synced on the client and it couldn’t find the entity. Solved by adding a 0.3 second delay.

Thanks for all effort anyway.