Advertisement
Guest User

Untitled

a guest
Aug 17th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. --References
  2. local ui_get = ui.get
  3. local ui_set = ui.set
  4. local ui_set_visible = ui.set_visible
  5. local console_cmd = client.exec
  6.  
  7. --Primary Weapon List
  8. local primary_weapons = {"-", "AWP", "SCAR20/G3SG1", "Scout", "M4/AK47", "Famas/Galil", "Aug/SG553", "M249/Negev", "Mag7/SawedOff", "Nova", "XM1014", "MP9/Mac10", "UMP45", "PPBizon", "MP7"}
  9.  
  10. --Secondary Weapon List
  11. local secondary_weapons = {"-", "CZ75/Tec9/FiveSeven", "P250", "Deagle/Revolver", "Dualies"}
  12.  
  13. --Grenade List
  14. local grenades = {"HE Grenade", "Molotov", "Smoke", "Flash", "Flash", "Decoy", "Decoy"}
  15.  
  16. --Utility List
  17. local utilities = {"Armor", "Helmet", "Zeus", "Defuser"}
  18.  
  19. --Logged grenade selection for limiting selections to 4
  20. local logged_grenades = {}
  21.  
  22. --Table of commands
  23. local translated_for_command = {
  24. ["AWP"] = "buy awp",
  25. ["SCAR20/G3SG1"] = "buy scar20",
  26. ["Scout"] = "buy ssg08",
  27. ["M4/AK47"] = "buy m4a1",
  28. ["Famas/Galil"] = "buy famas",
  29. ["Aug/SG553"] = "buy aug",
  30. ["M249/Negev"] = "buy m249",
  31. ["Mag7/SawedOff"] = "buy mag7",
  32. ["Nova"] = "buy nova",
  33. ["XM1014"] = "buy xm1014",
  34. ["MP9/Mac10"] = "buy mp9",
  35. ["UMP45"] = "buy ump45",
  36. ["PPBizon"] = "buy bizon",
  37. ["MP7"] = "buy mp7",
  38. ["CZ75/Tec9/FiveSeven"] = "buy tec9",
  39. ["P250"] = "buy p250",
  40. ["Deagle/Revolver"] = "buy deagle",
  41. ["Dualies"] = "buy elite",
  42. ["HE Grenade"] = "buy hegrenade",
  43. ["Molotov"] = "buy molotov",
  44. ["Smoke"] = "buy smokegrenade",
  45. ["Flash"] = "buy flashbang",
  46. ["Decoy"] = "buy decoy",
  47. ["Armor"] = "buy vest",
  48. ["Helmet"] = "buy vesthelm",
  49. ["Zeus"] = "buy taser 34",
  50. ["Defuser"] = "buy defuser"
  51. }
  52.  
  53. --Main Checkbox
  54. local checkbox_auto_buy = ui.new_checkbox("MISC", "Miscellaneous", "Auto Buy")
  55.  
  56. --Primary Components
  57. local combobox_primary_weapons = ui.new_combobox("MISC", "Miscellaneous", "Primary", primary_weapons)
  58.  
  59. --Secondary Components
  60. local combobox_secondary_weapons = ui.new_combobox("MISC", "Miscellaneous", "Secondary", secondary_weapons)
  61.  
  62. --Grenade Components
  63. local multiselect_grenades = ui.new_multiselect("MISC", "Miscellaneous", "Grenades", grenades)
  64.  
  65. --Utility Components
  66. local multiselect_utilities = ui.new_multiselect("MISC", "Miscellaneous", "Utilities", utilities)
  67.  
  68. --Set visibility
  69. ui_set_visible(combobox_primary_weapons, ui_get(checkbox_auto_buy))
  70. ui_set_visible(combobox_secondary_weapons, ui_get(checkbox_auto_buy))
  71. ui_set_visible(multiselect_grenades, ui_get(checkbox_auto_buy))
  72. ui_set_visible(multiselect_utilities, ui_get(checkbox_auto_buy))
  73.  
  74. local function on_round_prestart(e)
  75.  
  76. if ui_get(checkbox_auto_buy) then
  77.  
  78. --Secondary Weapon
  79. for k, v in pairs(translated_for_command) do
  80.  
  81. if k == ui_get(combobox_secondary_weapons) then
  82.  
  83. console_cmd(v)
  84.  
  85. end
  86.  
  87. end
  88.  
  89.  
  90. --Utility
  91. local utility_value = ui_get(multiselect_utilities)
  92.  
  93. for uindex = 1, table.getn(utility_value) do
  94.  
  95. local value_at_index = utility_value[uindex]
  96.  
  97. for k, v in pairs(translated_for_command) do
  98.  
  99. if k == value_at_index then
  100.  
  101. console_cmd(v)
  102.  
  103. end
  104.  
  105. end
  106.  
  107. end
  108.  
  109. --Primary Weapon
  110. for k, v in pairs(translated_for_command) do
  111.  
  112. if k == ui_get(combobox_primary_weapons) then
  113.  
  114. console_cmd(v)
  115.  
  116. end
  117.  
  118. end
  119.  
  120.  
  121. --Grenades
  122. local grenade_value = ui_get(multiselect_grenades)
  123.  
  124. for gindex = 1, table.getn(grenade_value) do
  125.  
  126. local value_at_index = grenade_value[gindex]
  127.  
  128. for k, v in pairs(translated_for_command) do
  129.  
  130. if k == value_at_index then
  131.  
  132. console_cmd(v)
  133.  
  134. end
  135.  
  136. end
  137.  
  138. end
  139.  
  140. end
  141.  
  142. end
  143.  
  144. --Set component visibility if auto buy is enabled
  145. local function visibility_callback()
  146.  
  147. local general_checked = ui_get(checkbox_auto_buy)
  148. ui_set_visible(combobox_primary_weapons, general_checked)
  149. ui_set_visible(combobox_secondary_weapons, general_checked)
  150. ui_set_visible(multiselect_grenades, general_checked)
  151. ui_set_visible(multiselect_utilities, general_checked)
  152.  
  153. end
  154.  
  155. --Limit the amount of options selected in the grenade multiselect component
  156. local function grenade_limit_callback(val)
  157.  
  158. local value = ui_get(val)
  159.  
  160. if table.getn(value) >= 5 then
  161.  
  162. ui_set(val, logged_grenades)
  163.  
  164. return
  165.  
  166. end
  167.  
  168. logged_grenades = value
  169.  
  170. end
  171.  
  172. ui.set_callback(checkbox_auto_buy, visibility_callback)
  173. ui.set_callback(multiselect_grenades, grenade_limit_callback)
  174.  
  175. client.set_event_callback("round_prestart", on_round_prestart)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement