I was doing a bit of testing in terms of sending an entity from the server to the client. However whenever I send it from the server it's fine it reads as
Entity [76] ["sent_ball"]
but when I receive I have
[NULL_ENTITY].
Of course when I try to get the model it returns something along the lines of
"tried to use a null entity".
Heres the code, any help would be great:
Server:
[code]
local SendEntity = ents.Create("sent_ball")
if(ValidEntity(SendEntity)) then
umsg.Start("SendEntityHook")
umsg.Entity(SendEntity)
umsg.End()
end
Msg(SendEntity)
[/code]
Client:
[code]
local function RecieveEntity(data)
Msg(data:ReadEntity())
end
usermessage.Hook("SendEntityHook", RecieveEntity)
[/code]
You probably have to use SendEntity:Spawn() first because right now you're sending an entity that hasnt been properly initialized.
Tried it, it didn't work. Any other suggestions?
Entities may not exist on the client before the client has seen it, best way to solve this is to use a timer and wait for the entity to become valid by sending the entity index instead and checking that until its not a null entity.
In my testing it may take a few seconds before the client has recognized the entity, which can be solved with repeating timers.
So, does the player actually have to see the entity on his screen in order for it to be initialized. Or can I just send an entity even though they don't see it. (And obviously use the timers to wait for it)
Sorry, you need to Log In to post a reply to this thread.