• Dynamically Sending Lua to a New Client
    2 replies, posted
I'm having an issue in trying to send some lua to the client via the net library when they join/map changes (net message sends string, which is then executed on client via RunString). I have the system working, but seems that if I try to hook into PlayerInitialSpawn to send the code from the server, the client isn't ready to receive it at that point and the transmission is lost. Adding a 3 second timer delay within the hook makes this work, but I'm trying to get it to load quicker than that (plus timers aren't that reliable since some clients could take longer). I've attempted to work the problem from the reverse side, having the client send a net message to the server that it's ready and cuing the server to begin it's sending, but this was subject to the same problem as above, with a 3 second delay needed to make it work. Both Initialize and InitPostEntity client-side produced the same result as before. Does anyone have some insight on this, or had to wrestle with this problem before? What is the soonest and quickest way to transmit lua dynamically to the client? I should also note that sending it via AddCSLuaFile isn't an option here, since the code being sent is dynamic.
Clients spawn in before they are fully connected. I made a custom hook which determines when the client can actually see and move, then sends the flag to the server, then the server syncs the data. The soonest and quickest is when they have control of their character.
Thanks for the suggestion =) It seems with some rearranging of my code however, I was able to get it working without the delay off a server-side PlayerInitialSpawn. Problem solved!
Sorry, you need to Log In to post a reply to this thread.