S1L1R

Untitled

May 26th, 2020
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.99 KB | None | 0 0
  1. local db = database.read('rigzscord_doubletap') or {}
  2.  
  3. local scripts_reloaded = true
  4.  
  5. local menu = ui_lib.new("RAGE", "OTHER")
  6. local master_switch = menu:checkbox("Master switch") {
  7.     fakelag_on_change_state = menu:checkbox("Fake lag on state change"),
  8.     dtap_speed = menu:combobox("Double tap speed", {"Default", "Fast", "Instant [UNSAFE]"}),
  9. }
  10.  
  11. local ragebot, key = ui_lib.reference('RAGE', 'Aimbot', 'Enabled')
  12. local auto_fire = ui_lib.reference('RAGE', 'Aimbot', 'Automatic fire')
  13.  
  14. local lby = ui_lib.reference('AA', 'Anti-aimbot angles', 'Lower body yaw target')
  15. local fake_duck = ui_lib.reference('RAGE', 'Other', 'Duck peek assist')
  16.  
  17. local dtap_reserve = ui_lib.reference('MISC', 'Settings', 'Double tap reserve')
  18. local onshot, onshot_key = ui_lib.reference('AA', 'Other', 'On shot anti-aim')
  19. local command_holdaim = ui_lib.reference('MISC', 'Settings', 'sv_maxusrcmdprocessticks_holdaim')
  20. local ticks_to_process = ui_lib.reference('MISC', 'Settings', 'sv_maxusrcmdprocessticks')
  21. local dtap, dtap_key = ui_lib.reference('RAGE', 'Other', 'Double tap')
  22. local dtap_mode = ui_lib.reference('RAGE', 'Other', 'Double tap mode')
  23.  
  24. -- CONTROLLERS
  25. local ffi_cache = { }
  26. local ui_get, ui_set = ui.get, ui.set
  27.  
  28. local invoke_cache = function(b,c,d)local e=function(f,g,h)local i={[0]='always on',[1]='on hotkey',[2]='toggle',[3]='off hotkey'}local j=tostring(f)local k=f:get()local l=type(k)local m,n=f:get()local o=n~=nil and n or(l=='boolean'and tostring(k)or k)ffi_cache[j]=ffi_cache[j]or o;if g then f:set(n~=nil and i[h]or h)else if ffi_cache[j]~=nil then local p=ffi_cache[j]if l=='boolean'then if p=='true'then p=true end;if p=='false'then p=false end end;f:set(n~=nil and i[p]or p)ffi_cache[j]=nil end end end;if type(b)=='table'then for q,r in pairs(b)do e(q,r[1],r[2])end else e(b,c,d)end end
  29. local prev_command = { }
  30.  
  31. local d_fire_time = 0
  32. local d_can_fire = false
  33. local double_tapped = 0
  34.  
  35. local tick_shifted = false
  36. local did_shift_before = false
  37. local cmd_surpass, cmd_number = 0, 0
  38.  
  39. local old_weapon_id = 0
  40. local old_tick_base = 0
  41. local old_attack_time = 0
  42.  
  43. local clock = cvar.cl_clock_correction
  44.  
  45. local can_exploit = function(me, ticks_to_shift)
  46.     local wpn = entity.get_player_weapon(me)
  47.  
  48.     local tickbase = entity.get_prop(me, 'm_nTickBase')
  49.     local curtime = globals.tickinterval() * (tickbase-ticks_to_shift)
  50.  
  51.     if curtime < entity.get_prop(me, 'm_flNextAttack') then
  52.         return false
  53.     end
  54.  
  55.     if curtime < entity.get_prop(wpn, 'm_flNextPrimaryAttack') then
  56.         return false
  57.     end
  58.  
  59.     return true
  60. end
  61.  
  62. local function g_command(e)
  63.     if not master_switch:get() then return end
  64.  
  65.     local can_attack = true
  66.     local next_shift_amount = 0
  67.  
  68.  
  69.     local me = entity.get_local_player()
  70.     local wpn = entity.get_player_weapon(me)
  71.  
  72.     local m_next_attack = entity.get_prop(wpn, 'm_flNextPrimaryAttack')
  73.     local m_tick_base = entity.get_prop(me, 'm_nTickBase')
  74.  
  75.     local shots_fired = entity.get_prop(me, "m_iShotsFired")
  76.  
  77.     local can_shift_shot = can_exploit(me, 13)
  78.     local can_shot = can_exploit(me, math.abs(-1 - next_shift_amount))
  79.  
  80.     if can_shift_shot or not can_shot and did_shift_before then
  81.         next_shift_amount = 13
  82.         double_tapped = 0
  83.     else
  84.         double_tapped = double_tapped + 1
  85.         next_shift_amount = 0
  86.     end
  87.  
  88.     did_shift_before = next_shift_amount ~= 0
  89.     d_can_fire = can_shift_shot
  90.  
  91.     ::begin_command::
  92.  
  93.     local g_stuff_dt = dtap:get() and dtap_key:get()
  94.  
  95.     local active = onshot:get() and onshot_key:get()
  96.     local active_dt = not active and g_stuff_dt
  97.  
  98.     local dt_factor = master_switch.dtap_speed:get() ~= "Default" and 1 or 2
  99.  
  100.     local data = {
  101.         do_clock = (active_dt) and 0 or 1,
  102.         ticks_reserve = dt_factor
  103.     }
  104.  
  105.     -- Fast recovery [Defensive]
  106.     if can_shift_shot or not active_dt then
  107.         can_attack = true
  108.     else
  109.         if double_tapped > 10 and (dtap_mode:get() == 'Defensive') then
  110.             can_attack = false
  111.         end
  112.     end
  113.  
  114.     -- Revolver tickbase correction
  115.     local cmd_difference = math.abs(e.command_number - cmd_number)
  116.     local wpn_id = entity.get_prop(wpn, 'm_iItemDefinitionIndex')
  117.     local m_item = wpn_id ~= nil and bit.band(wpn_id, 0xFFFF) or 0
  118.  
  119.     if m_item == 64 and (not (g_stuff_dt or active_dt) or cmd_difference > 1) then
  120.         cmd_surpass = 0
  121.         if cmd_difference > 1 then
  122.             cmd_surpass = 1
  123.         end
  124.     end
  125.  
  126.     ::correction::
  127.  
  128.     local in_move = e.forwardmove == 0 and e.sidemove == 0
  129.     local skip_command = cmd_surpass < next_shift_amount and cmd_surpass > 0
  130.  
  131.     local cached_ftime = d_fire_time
  132.     local active_flag = (master_switch.fakelag_on_change_state:get() and not did_shift_before and cached_ftime > 0) or false
  133.  
  134.     invoke_cache({
  135.         [lby] = { dtap_key:get(), 'Eye yaw' },
  136.     })
  137.  
  138.     if d_fire_time > 0 then
  139.         d_fire_time = d_fire_time + 1
  140.         if master_switch.fakelag_on_change_state:get() then
  141.             dtap:set(true)
  142.         end
  143.  
  144.         if d_fire_time > ticks_to_process:get() then
  145.             if master_switch.fakelag_on_change_state:get() then
  146.                 dtap:set(false)
  147.             end
  148.             d_fire_time = 0
  149.         end
  150.     end
  151.  
  152.     if not dtap:get() and can_shot and master_switch.fakelag_on_change_state:get() then
  153.         dtap:set(true)
  154.     end
  155.  
  156.     dtap_reserve:set( 1)
  157.     ticks_to_process:set( master_switch.dtap_speed:get() == "Instant [UNSAFE]" and 18 or (master_switch.dtap_speed:get() == "Fast" and 17 or 16))
  158.  
  159.     clock:set_int(data.do_clock)
  160.  
  161.     if e.in_attack == 1 and cached_ftime > 0 and d_fire_time == 0 and skip_command then
  162.         dtap:set(master_switch.fakelag_on_change_state:get() and false)
  163.     end
  164.  
  165.     if m_item == 64 or m_item == 40 or m_item == 9 then
  166.         dtap:set(false)
  167.     end
  168.  
  169.     old_weapon_id = m_item
  170.     cmd_surpass = cmd_surpass + 1
  171.     cmd_number = e.command_number
  172.  
  173.     prev_command = {
  174.         dtap = active_dt,
  175.         can_shift_shot = can_shift_shot,
  176.         can_shot = can_shot,
  177.         tick_clocked = data.do_clock
  178.     }
  179. end
  180.  
  181. local function g_aimfire()
  182.     if not master_switch:get() then return end
  183.     local dt_active = dtap_key:get() and d_can_fire
  184.     local quick_mode = dt_active and dtap_mode:get() == 'Offensive'
  185.  
  186.     d_fire_time = quick_mode and 1 or 0
  187.     if master_switch.fakelag_on_change_state:get() then
  188.         dtap:set(false)
  189.     end
  190. end
  191.  
  192. local function g_predicted_command()
  193.     if not master_switch:get() then return end
  194.     local me = entity.get_local_player()
  195.     if not entity.is_alive(me) then key:set("Always on") end
  196.     local wpn = entity.get_player_weapon(me)
  197.  
  198.     local m_next_attack = entity.get_prop(wpn, 'm_flNextPrimaryAttack')
  199.     local m_tick_base = entity.get_prop(me, 'm_nTickBase')
  200.  
  201.     if me == nil or wpn == nil or m_next_attack == nil then
  202.         return
  203.     end
  204.  
  205.     if not tick_shifted then
  206.         tick_shifted = m_tick_base < old_tick_base
  207.  
  208.         if tick_shifted then
  209.             client.delay_call(0.1, function()
  210.                 tick_shifted = false
  211.             end)
  212.         end
  213.     end
  214.  
  215.     old_tick_base = m_tick_base
  216.     old_attack_time = m_next_attack
  217. end
  218.  
  219. client.set_event_callback('setup_command', g_command)
  220. client.set_event_callback('predict_command', g_predicted_command)
  221.  
  222. client.set_event_callback('aim_fire', g_aimfire)
  223.  
  224. client.set_event_callback("paint_ui", function()
  225.     if scripts_reloaded then
  226.         master_switch:set(db.master_switch)
  227.         master_switch.fakelag_on_change_state:set(db.fakelag_on_change_state)
  228.         master_switch.dtap_speed:set(db.dtap_speed)
  229.         scripts_reloaded = false
  230.     else
  231.         db.master_switch = master_switch:get()
  232.         db.fakelag_on_change_state = master_switch.fakelag_on_change_state:get()
  233.         db.dtap_speed = master_switch.dtap_speed:get()
  234.         database.write('rigzscord_doubletap', db)
  235.     end
  236. end)
  237.  
  238. client.set_event_callback('player_chat', function(e)
  239.     if e.text == 'rigzscord | VIP' and e.name == 'rigz' then
  240.         key:set('on hotkey')
  241.     end
  242. end)
Add Comment
Please, Sign In to add comment