The_Belch

Block Bot

Jul 2nd, 2019
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. local font_icon = draw.CreateFont("Webdings", 30, 30)
  2. local font_warning = draw.CreateFont("Verdana", 15, 15)
  3.  
  4. -- Script --------
  5. local cur_scriptname = GetScriptName()
  6. local cur_version = "1.4"
  7. local git_version = "https://raw.githubusercontent.com/itisluiz/aimware_blockbot/master/version.txt"
  8. local git_repository = "https://raw.githubusercontent.com/itisluiz/aimware_blockbot/master/blockbot.lua"
  9. ------------------
  10.  
  11. -- UI Elements --
  12. local ref_msc_auto_other = gui.Reference("MISC", "AUTOMATION", "Other")
  13.  
  14. local key_blockbot = gui.Keybox(ref_msc_auto_other, "msc_blockbot", "Blockbot On Key", 0)
  15. local cob_blockbot_mode = gui.Combobox(ref_msc_auto_other, "msc_blockbot_mode", "Blockbot Mode", "Match Speed", "Maximum Speed")
  16. local chb_blockbot_retreat = gui.Checkbox(ref_msc_auto_other, "chb_blockbot_retreat", "Blockbot Retreat on BunnyHop", 0)
  17. -----------------
  18.  
  19. -- Check for updates
  20. local function git_update()
  21. if cur_version ~= http.Get(git_version) then
  22. local this_script = file.Open(cur_scriptname, "w")
  23. this_script:Write(http.Get(git_repository))
  24. this_script:Close()
  25. print("[Lua Scripting] " .. cur_scriptname .. " has updated itself from version " .. cur_version .. " to " .. http.Get(git_version))
  26. print("[Lua Scripting] Please reload " .. cur_scriptname)
  27. else
  28. print("[Lua Scripting] " .. cur_scriptname .. " is up-to-date")
  29. end
  30. end
  31.  
  32. -- Shared Variables
  33. local Target = nil
  34. local CrouchBlock = false
  35. local LocalPlayer = nil
  36.  
  37. local function OnFrameMain()
  38.  
  39. LocalPlayer = entities.GetLocalPlayer()
  40.  
  41. if LocalPlayer == nil or engine.GetServerIP() == nil then
  42. return
  43. end
  44.  
  45. if (key_blockbot:GetValue() == nil or key_blockbot:GetValue() == 0) or not LocalPlayer:IsAlive() then
  46. return
  47. end
  48.  
  49. if input.IsButtonDown(key_blockbot:GetValue()) and Target == nil then
  50.  
  51. for Index, Entity in pairs(entities.FindByClass("CCSPlayer")) do
  52. if Entity:GetIndex() ~= LocalPlayer:GetIndex() and Entity:IsAlive() then
  53. if Target == nil then
  54. Target = Entity;
  55. elseif vector.Distance({LocalPlayer:GetAbsOrigin()}, {Target:GetAbsOrigin()}) > vector.Distance({LocalPlayer:GetAbsOrigin()}, {Entity:GetAbsOrigin()}) then
  56. Target = Entity;
  57. end
  58. end
  59. end
  60.  
  61. elseif not input.IsButtonDown(key_blockbot:GetValue()) or not Target:IsAlive() then
  62. Target = nil
  63. end
  64.  
  65. if Target ~= nil then
  66. local NearPlayer_toScreen = {client.WorldToScreen(Target:GetBonePosition(5))}
  67.  
  68. if select(3, Target:GetHitboxPosition(0)) < select(3, LocalPlayer:GetAbsOrigin()) and vector.Distance({LocalPlayer:GetAbsOrigin()}, {Target:GetAbsOrigin()}) < 100 then
  69. CrouchBlock = true
  70. draw.Color(255, 255, 0, 255)
  71. else
  72. CrouchBlock = false
  73. draw.Color(255, 0, 0, 255)
  74. end
  75.  
  76. draw.SetFont(font_icon)
  77.  
  78. if NearPlayer_toScreen[1] ~= nil and NearPlayer_toScreen[2] ~= nil then
  79. draw.TextShadow(NearPlayer_toScreen[1] - select(1, draw.GetTextSize("x")) / 2, NearPlayer_toScreen[2], "x")
  80. end
  81.  
  82. end
  83.  
  84. end
  85.  
  86. local function OnCreateMoveMain(UserCmd)
  87.  
  88. if Target ~= nil then
  89. local LocalAngles = {UserCmd:GetViewAngles()}
  90. local VecForward = {vector.Subtract( {Target:GetAbsOrigin()}, {LocalPlayer:GetAbsOrigin()} )}
  91. local AimAngles = {vector.Angles( VecForward )}
  92. local TargetSpeed = vector.Length(Target:GetPropFloat("localdata", "m_vecVelocity[0]"), Target:GetPropFloat("localdata", "m_vecVelocity[1]"), Target:GetPropFloat("localdata", "m_vecVelocity[2]"))
  93.  
  94. if CrouchBlock then
  95. if cob_blockbot_mode:GetValue() == 0 then
  96. UserCmd:SetForwardMove( ( (math.sin(math.rad(LocalAngles[2]) ) * VecForward[2]) + (math.cos(math.rad(LocalAngles[2]) ) * VecForward[1]) ) * 10 )
  97. UserCmd:SetSideMove( ( (math.cos(math.rad(LocalAngles[2]) ) * -VecForward[2]) + (math.sin(math.rad(LocalAngles[2]) ) * VecForward[1]) ) * 10 )
  98. elseif cob_blockbot_mode:GetValue() == 1 then
  99. UserCmd:SetForwardMove( ( (math.sin(math.rad(LocalAngles[2]) ) * VecForward[2]) + (math.cos(math.rad(LocalAngles[2]) ) * VecForward[1]) ) * 200 )
  100. UserCmd:SetSideMove( ( (math.cos(math.rad(LocalAngles[2]) ) * -VecForward[2]) + (math.sin(math.rad(LocalAngles[2]) ) * VecForward[1]) ) * 200 )
  101. end
  102. else
  103. local DiffYaw = AimAngles[2] - LocalAngles[2]
  104.  
  105. if DiffYaw > 180 then
  106. DiffYaw = DiffYaw - 360
  107. elseif DiffYaw < -180 then
  108. DiffYaw = DiffYaw + 360
  109. end
  110.  
  111. if TargetSpeed > 285 and chb_blockbot_retreat:GetValue() then
  112. UserCmd:SetForwardMove(-math.abs(TargetSpeed))
  113. end
  114.  
  115. if cob_blockbot_mode:GetValue() == 0 then
  116. if math.abs(DiffYaw) > 0.75 then
  117. UserCmd:SetSideMove(450 * -DiffYaw)
  118. end
  119. elseif cob_blockbot_mode:GetValue() == 1 then
  120. if DiffYaw > 0.25 then
  121. UserCmd:SetSideMove(-450)
  122. elseif DiffYaw < -0.25 then
  123. UserCmd:SetSideMove(450)
  124. end
  125. end
  126.  
  127. end
  128.  
  129. end
  130.  
  131. end
  132.  
  133. if gui.GetValue("lua_allow_http") and gui.GetValue("lua_allow_cfg") then
  134. git_update()
  135. else
  136. print("[Lua Scripting] Please enable Lua HTTP and Lua script/config for automatic updates")
  137. end
  138.  
  139. callbacks.Register("Draw", OnFrameMain)
  140. callbacks.Register("CreateMove", OnCreateMoveMain)
Add Comment
Please, Sign In to add comment