Advertisement
Mister_Stefan

NL Bullettracer (LWv4)

Sep 27th, 2021
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. local eye_pos1 = {}
  2. client.add_callback(
  3.     "on_shot",
  4.     function(shot)
  5.         if shot.result ~= nil then
  6.             eye_pos = entitylist.get_local_player():get_origin()
  7.             eye_pos1[#eye_pos1 + 1] = {p_x = eye_pos.x, p_y = eye_pos.y, p_z = eye_pos.z + offset, a = 255}
  8.         end
  9.     end
  10. )
  11. events.register_event(
  12.     "bullet_impact",
  13.     function(e)
  14.         if engine.get_player_for_user_id(e:get_int("userid")) == engine.get_local_player_index() then
  15.             bullet_x, bullet_y, bullet_z = e:get_float("x"), e:get_float("y"), e:get_float("z")
  16.         end
  17.     end
  18. )
  19.  
  20. local function trace()
  21.     if entitylist.get_local_player() == nil then
  22.         return
  23.     end
  24.     offset = entitylist.get_local_player():get_prop_float("CBasePlayer", "m_vecViewOffset[2]")
  25.  
  26.     for i, b in pairs(eye_pos1) do
  27.         if b.a > 0 then
  28.             b.a = b.a - 1
  29.             local p2s = render.world_to_screen(vector.new(b.p_x, b.p_y, b.p_z))
  30.             local w2s = render.world_to_screen(vector.new(bullet_x, bullet_y, bullet_z))
  31.             if w2s.x == 0 and w2s.y == 0 then
  32.                 goto continue
  33.             end
  34.             if p2s.x == 0 and p2s.y == 0 then
  35.                 goto continue
  36.             end
  37.             render.draw_line(p2s.x, p2s.y, w2s.x, w2s.y, color.new(179, 255, 0, b.a))
  38.             ::continue::
  39.         else
  40.             eye_pos1[i] = nil
  41.         end
  42.     end
  43. end
  44. client.add_callback("on_paint", trace)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement