Advertisement
S1L1R

Hitchance precision

May 12th, 2020 (edited)
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.74 KB | None | 0 0
  1. local db = database.read('loader_hc') or {}
  2. local scripts_reloaded = true
  3.  
  4. local get, set = ui.get, ui.set
  5. local get_prop = entity.get_prop
  6. --------------------------------------------------------------------------------
  7. -- Script functions
  8. --------------------------------------------------------------------------------
  9. local cache = { }
  10. local script = {
  11.     variable = { '-', 'Automatic', 'Manual[beta]'},
  12.     global_dtap = nil,
  13.     var_cached = nil,
  14.    
  15.     active = false,
  16.    
  17.     time = -0.26,
  18.     max_time = 0,
  19. }
  20.  
  21. --------------------------------------------------------------------------------
  22. -- Menu functions
  23. --------------------------------------------------------------------------------
  24. local is_active = ui.new_checkbox('aa', 'other', 'Hitchance precision')
  25.  
  26. local hitchance = ui.reference('rage', 'aimbot', 'minimum hit chance')
  27. local f_duck = ui.reference('rage', 'other', 'duck peek assist')
  28. local fake_lag_lim = ui.reference('aa', 'fake lag', 'limit')
  29.  
  30. --------------------------------------------------------------------------------
  31. -- Function
  32. --------------------------------------------------------------------------------
  33. local function cache_process(condition, should_call, a, b)
  34.     local name = tostring(condition)
  35.     cache[name] = cache[name] ~= nil and cache[name] or get(condition)
  36.  
  37.     if should_call then
  38.         if type(a) == "function" then a() else
  39.             set(condition, a)
  40.         end
  41.     else
  42.         if cache[name] ~= nil then
  43.             if b ~= nil and type(b) == "function" then
  44.                 b(cache[name])
  45.             else
  46.                 set(condition, cache[name])
  47.             end
  48.  
  49.             cache[name] = nil
  50.         end
  51.     end
  52. end
  53.  
  54. --------------------------------------------------------------------------------
  55. -- Callback
  56. --------------------------------------------------------------------------------
  57. client.set_event_callback("predict_command", function()
  58.     script.time = -0.26
  59.  
  60.     local me = entity.get_local_player()
  61.     local weapon = entity.get_player_weapon(me)
  62.  
  63.     script.var_cached = script.var_cached ~= nil and script.var_cached or get(fake_lag_lim)
  64.     local m_flNextAttack = get_prop(me, "m_flNextAttack")
  65.     local next_attack = get_prop(weapon, "m_flNextPrimaryAttack")
  66.  
  67.     if next_attack == nil then
  68.         script.active = false
  69.         return
  70.     end
  71.    
  72.     local max_time = 0.69
  73.     local current_time = globals.curtime()
  74.     local m_flAttackTime = next_attack + 0.5
  75.  
  76.     local m_flNextAttack = m_flNextAttack + 0.5
  77.     local shift_time = m_flAttackTime - current_time
  78.  
  79.     if m_flAttackTime < m_flNextAttack then
  80.         max_time = 1.52
  81.         shift_time = m_flNextAttack - current_time
  82.     end
  83.  
  84.     script.time = shift_time
  85.     script.max_time = max_time
  86.  
  87.     local is_safe = max_time ~= 1.52 and shift_time > 0.1
  88.     local fd_active = get(f_duck)
  89.  
  90.     if fd_active then
  91.         set(fake_lag_lim, 14)
  92.     else
  93.         if script.var_cached ~= nil then
  94.             set(fake_lag_lim, script.var_cached)
  95.             script.var_cached = nil
  96.         end
  97.     end
  98.  
  99.     if get(is_active) then
  100.         local shots_fired = get_prop(me, "m_iShotsFired")
  101.  
  102.         cache_process(hitchance, is_safe and shots_fired > 0 and shift_time >= (max_time - 0.1), 0) ------------------
  103.     end
  104.  
  105. end)
  106.  
  107. --------------------------------------------------------------------------------
  108. -- BD callback
  109. --------------------------------------------------------------------------------
  110. client.set_event_callback("paint_ui", function()
  111.     if scripts_reloaded then
  112.         set(is_active, db.is_active or false)
  113.         scripts_reloaded = false
  114.     else
  115.         db.is_active = get(is_active)
  116.         database.write('loader_hc', db)
  117.     end
  118. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement