Advertisement
Mister_Stefan

Quick Peek (Aimware)

Oct 15th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.86 KB | None | 0 0
  1. -- global variables
  2. local peek_abs_origin = {}
  3. local is_peeking = false
  4. local has_shot = false
  5.  
  6. -- gui
  7. local ui_groupbox = gui.Groupbox(gui.Reference("MISC", "Movement"), "Auto Peek", 15, 573, 297, 900)
  8. local ui_checkbox = gui.Checkbox(gui.Reference("MISC", "Movement", "Auto Peek"), "lua_autopeek_enable", "Enable Auto Peek", false);
  9. local ui_keybox = gui.Keybox(gui.Reference("MISC", "Movement", "Auto Peek"), "lua_autopeek_key", "Auto Peek Bind", "A");
  10. local ui_checkbox_visualize = gui.Checkbox(gui.Reference("MISC", "Movement", "Auto Peek"), "lua_autopeek_visualize", "Visualize", false);
  11. local ui_color_picker = gui.ColorPicker(gui.Reference("MISC", "Movement", "Auto Peek"), "lua_autopeek_outlinecol", "Outline Color", 255, 255, 255, 255);
  12. local ui_color_picker2 = gui.ColorPicker(gui.Reference("MISC", "Movement", "Auto Peek"), "lua_autopeek_filcol", "Fill Color", 255, 255, 255, 255);
  13.  
  14. local function render(pos, radius)
  15.    
  16.     if not ui_checkbox_visualize:GetValue() then
  17.         return
  18.     end
  19.    
  20.     local center = {client.WorldToScreen(Vector3(pos.x, pos.y, pos.z)) }
  21.  
  22.     for degrees = 1, 360, 1 do
  23.        
  24.         local cur_point = nil;
  25.         local old_point = nil;
  26.  
  27.         if pos.z == nil then
  28.             cur_point = {pos.x + math.sin(math.rad(degrees)) * radius, pos.y + math.cos(math.rad(degrees)) * radius};  
  29.             old_point = {pos.x + math.sin(math.rad(degrees - 1)) * radius, pos.y + math.cos(math.rad(degrees - 1)) * radius};
  30.         else
  31.             cur_point = {client.WorldToScreen(Vector3(pos.x + math.sin(math.rad(degrees)) * radius, pos.y + math.cos(math.rad(degrees)) * radius, pos.z))};
  32.             old_point = {client.WorldToScreen(Vector3(pos.x + math.sin(math.rad(degrees - 1)) * radius, pos.y + math.cos(math.rad(degrees - 1)) * radius, pos.z))};
  33.         end
  34.                      
  35.         if cur_point[1] ~= nil and cur_point[2] ~= nil and old_point[1] ~= nil and old_point[2] ~= nil then    
  36.             -- fill
  37.             draw.Color(ui_color_picker2:GetValue())
  38.             draw.Triangle(cur_point[1], cur_point[2], old_point[1], old_point[2], center[1], center[2])
  39.             -- outline
  40.             draw.Color(ui_color_picker:GetValue())
  41.             draw.Line(cur_point[1], cur_point[2], old_point[1], old_point[2]);     
  42.         end
  43.        
  44.     end
  45.  
  46. end
  47.  
  48. callbacks.Register( "Draw", function()
  49.    
  50.     local m_local = entities.GetLocalPlayer()
  51.  
  52.     if input.IsButtonDown(ui_keybox:GetValue()) and not is_peeking then
  53.         peek_abs_origin = m_local:GetAbsOrigin()
  54.         is_peeking = true
  55.     end
  56.    
  57.     if is_peeking and input.IsButtonDown(ui_keybox:GetValue()) then
  58.         render(peek_abs_origin, 12)
  59.     else
  60.         if is_peeking then
  61.             peek_abs_origin = m_local:GetAbsOrigin()
  62.         end
  63.     end
  64. end)
  65.  
  66. callbacks.Register("CreateMove", function(cmd)
  67.    
  68.     local m_local = entities.GetLocalPlayer()
  69.  
  70.     if has_shot and input.IsButtonDown(ui_keybox:GetValue()) then
  71.        
  72.         local local_angle = {engine.GetViewAngles().x, engine.GetViewAngles().y, engine.GetViewAngles().z }
  73.         local world_forward = {vector.Subtract( {peek_abs_origin.x, peek_abs_origin.y, peek_abs_origin.z},  {m_local:GetAbsOrigin().x, m_local:GetAbsOrigin().y, m_local:GetAbsOrigin().z} )}
  74.        
  75.         cmd.forwardmove = ( ( (math.sin(math.rad(local_angle[2]) ) * world_forward[2]) + (math.cos(math.rad(local_angle[2]) ) * world_forward[1]) ) * 200 )
  76.         cmd.sidemove = ( ( (math.cos(math.rad(local_angle[2]) ) * -world_forward[2]) + (math.sin(math.rad(local_angle[2]) ) * world_forward[1]) ) * 200 )
  77.  
  78.         if vector.Length(world_forward) < 10 then
  79.             has_shot = false
  80.         end
  81.     end
  82. end)
  83.  
  84. client.AllowListener( "player_hurt" );
  85.  
  86. callbacks.Register( "FireGameEvent", function(Event)
  87.  
  88.         local local_index = client.GetLocalPlayerIndex();
  89.         local victim_index = client.GetPlayerIndexByUserID( Event:GetInt( "userid" ) );
  90.         local attacker_index = client.GetPlayerIndexByUserID( Event:GetInt( "attacker" ) );
  91.  
  92.         if ( victim_index == local_index and attacker_index ~= local_index ) then
  93.             has_shot = true
  94.         end
  95. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement