Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 KB | None | 0 0
  1. local list = { "Default", "Hit ground" }
  2.  
  3. local alpha = 0
  4. local enabled = ui.new_checkbox("AA", "Fake lag", "Lag comp shifter")
  5. local condition = ui.new_multiselect("AA", "Fake lag", "\n lagcomp_shifter_condition", list)
  6.  
  7. local amount = ui.reference("AA", "Fake lag", "Amount")
  8. local variance = ui.reference("AA", "Fake lag", "Variance")
  9. local custom_triggers = ui.reference("AA", "Fake lag", "Customize triggers")
  10. local onshot_fakelag = ui.reference("AA", "Fake lag", "Fake lag while shooting")
  11.  
  12. local phases = {
  13. { amount = "Maximum", variance = 0 },
  14. { amount = "Dynamic", variance = 0 },
  15. { amount = "Maximum", variance = 36 },
  16. { amount = "Dynamic", variance = 0 },
  17. { amount = "Maximum", variance = 68 },
  18. { amount = "Dynamic", variance = 0 },
  19. { amount = "Fluctuate", variance = 0 },
  20. -- { amount = "Fluctuate", variance = 100 },
  21. }
  22.  
  23. local data = {
  24. current_phase = 0,
  25. prev_choked = 14,
  26. }
  27.  
  28. local cache = { }
  29. local ui_get, ui_set = ui.get, ui.set
  30. local entity_is_alive = entity.is_alive
  31. local renderer_measure_text = renderer.measure_text
  32. local renderer_indicator = renderer.indicator
  33. local renderer_rectangle = renderer.rectangle
  34.  
  35. local bit_band = bit.band
  36. local math_sqrt = math.sqrt
  37. local entity_get_prop = entity.get_prop
  38. local entity_get_local_player = entity.get_local_player
  39.  
  40. local cache_process = function(name, condition, should_call, VAR)
  41. local hotkey_modes = {
  42. [0] = "always on",
  43. [1] = "on hotkey",
  44. [2] = "toggle",
  45. [3] = "off hotkey"
  46. }
  47.  
  48. local _cond = ui_get(condition)
  49. local _type = type(_cond)
  50.  
  51. local value, mode = ui_get(condition)
  52. local finder = mode ~= nil and mode or (_type == "boolean" and tostring(_cond) or _cond)
  53. cache[name] = cache[name] ~= nil and cache[name] or finder
  54.  
  55. if should_call then ui_set(condition, mode ~= nil and hotkey_modes[VAR] or VAR) else
  56. if cache[name] ~= nil then
  57. local _cache = cache[name]
  58.  
  59. if _type == "boolean" then
  60. if _cache == "true" then _cache = true end
  61. if _cache == "false" then _cache = false end
  62. end
  63.  
  64. ui_set(condition, mode ~= nil and hotkey_modes[_cache] or _cache)
  65. cache[name] = nil
  66. end
  67. end
  68. end
  69.  
  70. local function compare(tab, val)
  71. for i = 1, #tab do
  72. if tab[i] == val then
  73. return true
  74. end
  75. end
  76.  
  77. return false
  78. end
  79.  
  80. client.set_event_callback("setup_command", function(c)
  81. local get_prop = function(...)
  82. return entity_get_prop(entity_get_local_player(), ...)
  83. end
  84.  
  85. local conditions = ui_get(condition)
  86.  
  87. local x, y, z = get_prop("m_vecVelocity")
  88. local in_air = c.in_jump == 1 or bit_band(get_prop("m_fFlags"), 1) ~= 1
  89.  
  90. local is_active = ui_get(enabled) and (
  91. (compare(conditions, list[1]) and not in_air and math.sqrt(x^2 + y^2) > 1) or
  92. (compare(conditions, list[2]) and in_air)
  93. )
  94.  
  95. if is_active then
  96. if alpha < 248 then
  97. alpha = alpha + 8
  98. end
  99. else
  100. if alpha > 7 then
  101. alpha = alpha - 8
  102. end
  103. end
  104.  
  105. if c.chokedcommands < data.prev_choked then
  106. data.current_phase = data.current_phase + 1
  107.  
  108. if data.current_phase > #phases then
  109. data.current_phase = 1
  110. end
  111. end
  112.  
  113. -- cache_process("onshot_fakelag", onshot_fakelag, is_active, true)
  114. cache_process("custom_triggers", custom_triggers, is_active, false)
  115. cache_process("amount", amount, is_active, phases[data.current_phase].amount)
  116. cache_process("variance", variance, is_active, phases[data.current_phase].variance)
  117.  
  118. data.prev_choked = c.chokedcommands
  119. end)
  120.  
  121. client.set_event_callback("paint", function(c)
  122. local me = entity_get_local_player()
  123.  
  124. if not ui_get(enabled) or not entity_is_alive(me) then
  125. return
  126. end
  127.  
  128. if alpha > 0 then
  129. local text = "CL"
  130. local width, height = renderer_measure_text("+", text)
  131. local y = renderer_indicator(255, 255, 255, alpha > 150 and 150 or alpha, text)
  132.  
  133. renderer_rectangle(10, y + 26, width, 5, 0, 0, 0, alpha > 150 and 150 or alpha)
  134. renderer_rectangle(11, y + 27, ((width - 2) / #phases) * data.current_phase, 3, 133, 197, 12, alpha)
  135. end
  136. end)
  137.  
  138. local _callback = function(self)
  139. ui.set_visible(condition, ui_get(self))
  140. end
  141.  
  142. ui.set_callback(enabled, _callback)
  143. _callback(enabled)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement