Advertisement
demonlxrd

HELL.lua

Jul 22nd, 2021
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.09 KB | None | 0 0
  1. local csgo_weapons = require "gamesense/csgo_weapons"
  2.  
  3. -- local variables for API functions. any changes to the line below will be lost on re-generation
  4. local client_exec, client_set_event_callback, client_unset_event_callback, client_userid_to_entindex, entity_get_local_player, entity_get_prop, ui_get, ui_set, ui_set_visible =
  5. client.exec, client.set_event_callback, client.unset_event_callback, client.userid_to_entindex, entity.get_local_player, entity.get_prop, ui.get, ui.set, ui.set_visible
  6.  
  7. --autobuy v2
  8. local primary_weapons = {
  9. "-",
  10. "AWP",
  11. "SCAR20/G3SG1",
  12. "Scout",
  13. "M4/AK47",
  14. "Famas/Galil",
  15. "Aug/SG553",
  16. "M249",
  17. "Negev",
  18. "Mag7/SawedOff",
  19. "Nova",
  20. "XM1014",
  21. "MP9/Mac10",
  22. "UMP45",
  23. "PPBizon",
  24. "MP7"
  25. }
  26.  
  27. local secondary_weapons = {
  28. "-",
  29. "CZ75/Tec9/FiveSeven",
  30. "P250",
  31. "Deagle/Revolver",
  32. "Dualies"
  33. }
  34.  
  35. local grenades = {
  36. "HE Grenade",
  37. "Molotov",
  38. "Smoke",
  39. "Flash",
  40. "Flash",
  41. "Decoy",
  42. "Decoy"
  43. }
  44.  
  45. local utilities = {
  46. "Armor",
  47. "Helmet",
  48. "Zeus",
  49. "Defuser"
  50. }
  51.  
  52. local prices = {
  53. ["AWP"] = csgo_weapons["weapon_awp"].in_game_price,
  54. ["SCAR20/G3SG1"] = csgo_weapons["weapon_scar20"].in_game_price,
  55. ["Scout"] = csgo_weapons["weapon_ssg08"].in_game_price,
  56. ["M4/AK47"] = csgo_weapons["weapon_m4a1"].in_game_price,
  57. ["Famas/Galil"] = csgo_weapons["weapon_famas"].in_game_price,
  58. ["Aug/SG553"] = csgo_weapons["weapon_aug"].in_game_price,
  59. ["M249"] = csgo_weapons["weapon_m249"].in_game_price,
  60. ["Negev"] = csgo_weapons["weapon_negev"].in_game_price,
  61. ["Mag7/SawedOff"] = csgo_weapons["weapon_mag7"].in_game_price,
  62. ["Nova"] = csgo_weapons["weapon_nova"].in_game_price,
  63. ["XM1014"] = csgo_weapons["weapon_xm1014"].in_game_price,
  64. ["MP9/Mac10"] = csgo_weapons["weapon_mp9"].in_game_price,
  65. ["UMP45"] = csgo_weapons["weapon_ump45"].in_game_price,
  66. ["PPBizon"] = csgo_weapons["weapon_bizon"].in_game_price,
  67. ["MP7"] = csgo_weapons["weapon_mp7"].in_game_price,
  68. ["CZ75/Tec9/FiveSeven"] = csgo_weapons["weapon_tec9"].in_game_price,
  69. ["P250"] = csgo_weapons["weapon_p250"].in_game_price,
  70. ["Deagle/Revolver"] = csgo_weapons["weapon_deagle"].in_game_price,
  71. ["Dualies"] = csgo_weapons["weapon_elite"].in_game_price,
  72. ["HE Grenade"] = csgo_weapons["weapon_hegrenade"].in_game_price,
  73. ["Molotov"] = csgo_weapons["weapon_molotov"].in_game_price,
  74. ["Smoke"] = csgo_weapons["weapon_smokegrenade"].in_game_price,
  75. ["Flash"] = csgo_weapons["weapon_flashbang"].in_game_price,
  76. ["Decoy"] = csgo_weapons["weapon_decoy"].in_game_price,
  77. ["Armor"] = csgo_weapons["item_kevlar"].in_game_price,
  78. ["Helmet"] = csgo_weapons["item_assaultsuit"].in_game_price,
  79. ["Zeus"] = csgo_weapons["weapon_taser"].in_game_price,
  80. ["Defuser"] = csgo_weapons["item_cutters"].in_game_price,
  81. ["-"] = 0
  82. }
  83.  
  84. local commands = {
  85. ["AWP"] = "buy awp",
  86. ["SCAR20/G3SG1"] = "buy scar20",
  87. ["Scout"] = "buy ssg08",
  88. ["M4/AK47"] = "buy m4a1",
  89. ["Famas/Galil"] = "buy famas",
  90. ["Aug/SG553"] = "buy aug",
  91. ["M249"] = "buy m249",
  92. ["Negev"] = "buy negev",
  93. ["Mag7/SawedOff"] = "buy mag7",
  94. ["Nova"] = "buy nova",
  95. ["XM1014"] = "buy xm1014",
  96. ["MP9/Mac10"] = "buy mp9",
  97. ["UMP45"] = "buy ump45",
  98. ["PPBizon"] = "buy bizon",
  99. ["MP7"] = "buy mp7",
  100. ["CZ75/Tec9/FiveSeven"] = "buy tec9",
  101. ["P250"] = "buy p250",
  102. ["Deagle/Revolver"] = "buy deagle",
  103. ["Dualies"] = "buy elite",
  104. ["HE Grenade"] = "buy hegrenade",
  105. ["Molotov"] = "buy molotov",
  106. ["Smoke"] = "buy smokegrenade",
  107. ["Flash"] = "buy flashbang",
  108. ["Decoy"] = "buy decoy",
  109. ["Armor"] = "buy vest",
  110. ["Helmet"] = "buy vesthelm",
  111. ["Zeus"] = "buy taser 34",
  112. ["Defuser"] = "buy defuser",
  113. ["-"] = ""
  114. }
  115.  
  116. --new menu
  117. local menu = {
  118. enabled = ui.new_checkbox("MISC", "Miscellaneous", "Autobuy (v2)"),
  119. hide = ui.new_checkbox("MISC", "Miscellaneous", "Hide autobuy"),
  120. primary = ui.new_combobox("MISC", "Miscellaneous", "Primary", primary_weapons),
  121. secondary = ui.new_combobox("MISC", "Miscellaneous", "Secondary", secondary_weapons),
  122. grenades = ui.new_multiselect("MISC", "Miscellaneous", "Grenades", grenades),
  123. utilities = ui.new_multiselect("MISC", "Miscellaneous", "Utilities", utilities),
  124. cost_based = ui.new_checkbox("MISC", "Miscellaneous", "Cost based"),
  125. threshold = ui.new_slider("MISC", "Miscellaneous", "Balance override", 0, 16000, 0, true, "$", 1, {[0] = "Auto"}),
  126. primary_2 = ui.new_combobox("MISC", "Miscellaneous", "Backup primary", primary_weapons),
  127. secondary_2 = ui.new_combobox("MISC", "Miscellaneous", "Backup secondary", secondary_weapons),
  128. grenades_2 = ui.new_multiselect("MISC", "Miscellaneous", "Backup grenades", grenades),
  129. utilities_2 = ui.new_multiselect("MISC", "Miscellaneous", "Backup utilities", utilities),
  130. }
  131.  
  132. --weapon prices
  133. local weapon_cost = 0
  134.  
  135. local function calculate_weapon_prices()
  136. weapon_cost = 0
  137. --utilities
  138. local utility_purchase = ui_get(menu.utilities)
  139. for i = 1, #utility_purchase do
  140. local n = utility_purchase[i]
  141.  
  142. weapon_cost = weapon_cost + prices[n]
  143. end
  144.  
  145. --secondary
  146. weapon_cost = weapon_cost + prices[ui_get(menu.secondary)]
  147.  
  148. --primary
  149. weapon_cost = weapon_cost + prices[ui_get(menu.primary)]
  150.  
  151. --grenades
  152. local grenade_purchase = ui_get(menu.grenades)
  153. for i = 1, #grenade_purchase do
  154. local n = grenade_purchase[i]
  155.  
  156. weapon_cost = weapon_cost + prices[n]
  157. end
  158. end
  159.  
  160. -- split into two funcs because otherwise the storing gets fked up
  161. local logged_grenades_full = {}
  162. local logged_grenades_eco = {}
  163.  
  164. local function grenade_limit_callback_full()
  165. local total_nades = ui_get(menu.grenades)
  166.  
  167. if #total_nades > 4 then
  168. ui_set(menu.grenades, logged_grenades)
  169. return
  170. end
  171.  
  172. logged_grenades_full = total_nades
  173. prepare_cmd()
  174. end
  175.  
  176. local function grenade_limit_callback_eco()
  177. local total_nades = ui_get(menu.grenades_2)
  178.  
  179. if #total_nades > 4 then
  180. ui_set(menu.grenades_2, logged_grenades)
  181. return
  182. end
  183.  
  184. logged_grenades_eco = total_nades
  185. prepare_cmd()
  186. end
  187.  
  188. --cmd handler
  189. local cmd_full = ""
  190. local cmd_eco = ""
  191.  
  192. local function prepare_cmd()
  193. --reset vars
  194. cmd_full = ""
  195. cmd_eco = ""
  196.  
  197. --full buy cmd
  198. --secondary
  199. cmd_full = cmd_full .. commands[ui_get(menu.secondary)] .. ";"
  200. --utilities
  201. local utility_purchase = ui_get(menu.utilities)
  202. for i = 1, #utility_purchase do
  203. cmd_full = cmd_full .. commands[utility_purchase[i]] .. ";"
  204. end
  205. --primary
  206. cmd_full = cmd_full .. commands[ui_get(menu.primary)] .. ";"
  207. --grenades
  208. local grenade_purchase = ui_get(menu.grenades)
  209. for i = 1, #grenade_purchase do
  210. cmd_full = cmd_full .. commands[grenade_purchase[i]] .. ";"
  211. end
  212.  
  213. --eco buy cmd
  214. --secondary
  215. cmd_eco = cmd_eco .. commands[ui_get(menu.secondary_2)] .. ";"
  216. --utilities
  217. local utility_purchase = ui_get(menu.utilities_2)
  218. for i = 1, #utility_purchase do
  219. cmd_eco = cmd_eco .. commands[utility_purchase[i]] .. ";"
  220. end
  221. --primary
  222. local prim = commands[ui_get(menu.primary_2)]
  223. cmd_eco = cmd_eco .. commands[ui_get(menu.primary_2)] .. ";"
  224. --grenades
  225. local grenade_purchase = ui_get(menu.grenades_2)
  226. for i = 1, #grenade_purchase do
  227. cmd_eco = cmd_eco .. commands[grenade_purchase[i]] .. ";"
  228. end
  229.  
  230. calculate_weapon_prices()
  231. end
  232.  
  233. local round_started = false
  234.  
  235. --callbacks
  236. local function on_net_update_end(e)
  237. if round_started then
  238. local money = entity_get_prop(entity_get_local_player(), "m_iAccount")
  239.  
  240. local threshold = ui_get(menu.threshold)
  241.  
  242. local price_threshold = 0
  243.  
  244. if ui_get(menu.cost_based) and (threshold == 0) then
  245. price_threshold = weapon_cost
  246. elseif (threshold ~= 0) then
  247. price_threshold = ui_get(menu.threshold)
  248. end
  249.  
  250. if money < price_threshold then
  251. client_exec(cmd_eco)
  252. else
  253. client_exec(cmd_full)
  254. end
  255.  
  256. round_started = false
  257. end
  258. end
  259.  
  260. local function on_round_prestart(e)
  261. round_started = true
  262. end
  263.  
  264. local function on_player_spawn(e)
  265. if not round_started and not e.inrestart and client_userid_to_entindex(e.userid) == entity_get_local_player() then
  266. round_started = true
  267. end
  268. end
  269.  
  270. --visibility
  271. local function handle_vis()
  272. local state = ui_get(menu.enabled)
  273. local state2 = (not ui_get(menu.hide))
  274. local state3 = ui_get(menu.cost_based)
  275.  
  276. ui_set_visible(menu.hide, state)
  277.  
  278. if state and state2 then
  279. ui_set_visible(menu.primary, state)
  280. ui_set_visible(menu.secondary, state)
  281. ui_set_visible(menu.grenades, state)
  282. ui_set_visible(menu.utilities, state)
  283. ui_set_visible(menu.cost_based, state)
  284. ui_set_visible(menu.threshold, state3)
  285. ui_set_visible(menu.primary_2, state3)
  286. ui_set_visible(menu.secondary_2, state3)
  287. ui_set_visible(menu.grenades_2, state3)
  288. ui_set_visible(menu.utilities_2, state3)
  289. elseif not state2 then
  290. ui_set_visible(menu.primary, state2)
  291. ui_set_visible(menu.secondary, state2)
  292. ui_set_visible(menu.grenades, state2)
  293. ui_set_visible(menu.utilities, state2)
  294. ui_set_visible(menu.cost_based, state2)
  295. ui_set_visible(menu.threshold, state2)
  296. ui_set_visible(menu.primary_2, state2)
  297. ui_set_visible(menu.secondary_2, state2)
  298. ui_set_visible(menu.grenades_2, state2)
  299. ui_set_visible(menu.utilities_2, state2)
  300. else
  301. ui_set_visible(menu.primary, state)
  302. ui_set_visible(menu.secondary, state)
  303. ui_set_visible(menu.grenades, state)
  304. ui_set_visible(menu.utilities, state)
  305. ui_set_visible(menu.cost_based, state)
  306. ui_set_visible(menu.threshold, state)
  307. ui_set_visible(menu.primary_2, state)
  308. ui_set_visible(menu.secondary_2, state)
  309. ui_set_visible(menu.grenades_2, state)
  310. ui_set_visible(menu.utilities_2, state)
  311. end
  312.  
  313. end
  314.  
  315. local function on_script_toggle()
  316. local state = ui.get(menu.enabled)
  317. local update_callback = state and client_set_event_callback or client_unset_event_callback
  318. update_callback("net_update_end", on_net_update_end)
  319. update_callback("round_prestart", on_round_prestart)
  320. update_callback("player_spawn", on_player_spawn)
  321.  
  322. handle_vis()
  323. end
  324.  
  325. --init
  326. do
  327. ui.set_callback(menu.enabled, on_script_toggle)
  328. on_script_toggle()
  329. ui.set_callback(menu.grenades, grenade_limit_callback_full)
  330. ui.set_callback(menu.grenades_2, grenade_limit_callback_eco)
  331.  
  332. ui.set_callback(menu.primary, prepare_cmd)
  333. ui.set_callback(menu.secondary, prepare_cmd)
  334. ui.set_callback(menu.grenades, prepare_cmd)
  335. ui.set_callback(menu.utilities, prepare_cmd)
  336.  
  337. ui.set_callback(menu.primary_2, prepare_cmd)
  338. ui.set_callback(menu.secondary_2, prepare_cmd)
  339. ui.set_callback(menu.grenades_2, prepare_cmd)
  340. ui.set_callback(menu.utilities_2, prepare_cmd)
  341.  
  342. prepare_cmd()
  343.  
  344. ui.set_callback(menu.hide, handle_vis)
  345. ui.set_callback(menu.cost_based, handle_vis)
  346. handle_vis()
  347. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement