Use the FileNetMessages extension, specifically the FNM_RequestFile function. However, this will initiate a full file transfer, so you will need to block OnFileReceive immediately on the file you request.
Original post:
Spoiler
I need a way to determine when all available clients (that don't have downloads turned off or sprays disabled) have downloaded a specific material file before precaching it on the server. How would I do this?
See the spoiler for more context on what I'm trying to accomplish. My issue was not giving the client enough time to download the material before precaching it. I am able to get the decal to display using a delay of 0.2 seconds, but I feel like this is a hacky solution that could easily go wrong if a client takes longer than 0.2 seconds to download the file.
Spoiler
I am writing a plugin that can "respray" a client's spray. The end goal is to allow me to "manipulate" the spray by creating special VMT files for changing attributes like $decalscale, and sending those to clients on the fly.
Step by step, the plugin does the following:
Determines the resulting filename of the player's spray using GetPlayerDecalFile
Creates a VMT material file that uses the spray as a $basetexture
Creates a decal using the freshly generated VMT material
Everything works almost properly, the file is sent mid-game and I am able to use my spray in decals that are larger than 64x64 Hammer units:
However, the decal only displays after I attempt to spray, then change the map, then spray again. The very first time I try to spray the freshly-generated material, I get a pink square instead, indicating a missing texture:
How can I get the client to initialize the material on their side and display it properly without needing to reload the map?
I've attached the plugin below; it requires the aforementioned extension to compile properly. Use the command !writevmt to try spraying.