• Aiming beam
    9 replies, posted
I want to make a script for admins so they can see where the player is looking in witch direction. How can i posibly make a short beam that shows where they aim from their weapon?
Something like this. [lua] local targets = {} hook.Add("HUDPaint" , "DrawAim" , function() for k , v in pairs(targets) do if ValidEntity(v:GetActiveWeapon()) then local pos = v:GetActiveWeapon():GetPos() local endpos = v:GetEyeTraceNoCursor().HitPos cam.Start3D(EyePos() , EyeAngles()) render.SetMaterial(Material("Trails/laser")) cam.IgnoreZ(false) render.DrawBeam(pos , endpos , 8 , 2 , 0 , Color( 0 , 255 , 0 , 255 )) cam.IgnoreZ(true) cam.End3D() end end end ) concommand.Add("spec" , function(p , c , a) for k , v in ipairs(player.GetAll()) do local removed = false if string.find(string.lower(v:Nick()) , string.lower(a[1])) then for a , b in pairs(targets) do if b == v then table.remove(targets , a) removed = true end end if not removed then table.insert(targets , v) end end end end )[/lua]
Thanks, is it possible to make the beam like 50 units? Best regards
Change this [lua]local endpos = v:GetEyeTraceNoCursor().HitPos[/lua] To this [lua]local endpos = v:EyePos() + Vector(0 , 50 , 0)[/lua]
ok thanks will try
It might not work. If not, just fiddle about with the values until you get it to work.
it will not show where the person aims since endpos is static and never change (always point in the same direction).
[lua] local pos = v:GetShootPos() local endpos = pos+v:GetAimVector()*50 [/lua]
[QUOTE=ralle105;22516221][lua] local pos = v:GetShootPos() local endpos = pos+v:GetAimVector()*50 [/lua][/QUOTE] Yeah, that will work. Can't believe I forgot about it. Also in the news: GMod update released (I think)
nice thanks ralle105 and FlapJack a lot
Sorry, you need to Log In to post a reply to this thread.