env_projectedtexture Flashlight

So I am working on making a tac light attachment for a weapon and I want a env_projectedtexture to follow the movement of the weapon ect. I have a basic understanding of how env_projectedtexture works. However I do not understand how to get it to follow the view model since it can only be created server side.

Get the weapon of the player, and look what attachments the weapon world model has (http://wiki.garrysmod.com/page/Entity/GetAttachments). Then just parent it to a fitting one.
If you only set the of the pos flashlight serverside though, it might look shitty in high ping situations.

Edit:
Read bfgs message further down

And it will also look terrible with any weapon animations or player animations.

I was trying to do this exact thing but I took into account all the issues and quite frankly, it’s a bad idea.

NVM I lied
It is possible. Apparently while created serverside, it is rendered on client, and this was verified by LEETNOOB. so you CAN actually pull this off.
I believe all you have to do is:

  1. ents.Create it
  2. SetParent
  3. Set the angles

Which is actually very surprising.

[editline]21st February 2014[/editline]

And according to LEET you do this all serverside… which is mildly confusing but it works.

I’d recommend you to create single env_projected_texture on server for every player. And only viewmodel uses it. So you just SetRenderOrigin/SetRenderAngles the projtext entity to your viewmodel’s attachment or something.