Lasers

Good Day, A Friend and I are working on a game mode and its my job to create the weapons, all is going well but I’m stuck and was hoping one of you LUA Gods out there would help me. I need to make my weapons shoot lasers, like the lasers you can make shoot out of the Gmod turret, and i need to know how the change the color of the lasers as-well, but i have no clue how to do this, Please help. You will get Credit for your help.

Thank you

Oh, the laser tracer? When you’re shooting the bullet, for the tracer name just put LaserTracer. As for changing the colour, just edit the tracer effect’s init.lua file, specifically the colour value in this bit:

[lua]
render.DrawBeam( self.EndPos - self.Dir * (fDelta - sinWave * self.Length ),
self.EndPos - self.Dir * (fDelta + sinWave * self.Length ),
2 + sinWave * 16,
1,
0,
Color( 0, 255, 0, 255 ) ) --here
[/lua]

Thank You very much you have no idea how much further this brings Us! :smiley:

[editline]09:43PM[/editline]

It appears i have run into a problem with you solution, i did just as you said and im pretty sure your right, but now its not allowing me to spawn my weapons, here is the code so you can see what im dealing with…


 "bullet.Lasertraser   = 1									// Show a tracer on every x bullets" 

       that is all i changed and now it wont allow me to spawn my weapon, would you know what i might have done wrong?

Ah, I see what you’re doing. I meant as in doing this:



bullet.TracerName = "LaserTracer"


rather than changing bullet.Tracer to bullet.LaserTracer. bullet.Tracer is just how often there’ll be a tracer on the bullets, bullet.TracerName is the name of the effect you want to see between the muzzle and where the bullet hit.