Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.72 KB | None | 0 0
  1. local globals_realtime = globals.realtime
  2. local globals_curtime = globals.curtime
  3. local globals_frametime = globals.frametime
  4. local globals_absolute_frametime = globals.absoluteframetime
  5. local globals_maxplayers = globals.maxplayers
  6. local globals_tickcount = globals.tickcount
  7. local globals_tickinterval = globals.tickinterval
  8. local globals_mapname = globals.mapname
  9.  
  10. local client_set_event_callback = client.set_event_callback
  11. local client_console_log = client.log
  12. local client_color_log = client.color_log
  13. local client_console_cmd = client.exec
  14. local client_userid_to_entindex = client.userid_to_entindex
  15. local client_get_cvar = client.get_cvar
  16. local client_set_cvar = client.set_cvar
  17. local client_draw_debug_text = client.draw_debug_text
  18. local client_draw_hitboxes = client.draw_hitboxes
  19. local client_draw_indicator = client.draw_indicator
  20. local client_random_int = client.random_int
  21. local client_random_float = client.random_float
  22. local client_draw_text = client.draw_text
  23. local client_draw_rectangle = client.draw_rectangle
  24. local client_draw_line = client.draw_line
  25. local client_draw_gradient = client.draw_gradient
  26. local client_draw_cricle = client.draw_circle
  27. local client_draw_circle_outline = client.draW_circle_outline
  28. local client_world_to_screen = client.world_to_screen
  29. local client_screen_size = client.screen_size
  30. local client_visible = client.visible
  31. local client_delay_call = client.delay_call
  32. local client_latency = client.latency
  33. local client_camera_angles = client.camera_angles
  34. local client_trace_line = client.trace_line
  35. local client_eye_position = client.eye_position
  36. local client_set_clan_tag = client.set_clan_tag
  37. local client_system_time = client.system_time
  38.  
  39. local entity_get_local_player = entity.get_local_player
  40. local entity_get_all = entity.get_all
  41. local entity_get_players = entity.get_players
  42. local entity_get_classname = entity.get_classname
  43. local entity_set_prop = entity.set_prop
  44. local entity_get_prop = entity.get_prop
  45. local entity_is_enemy = entity.is_enemy
  46. local entity_get_player_name = entity.get_player_name
  47. local entity_get_player_weapon = entity.get_player_weapon
  48. local entity_hitbox_position = entity.hitbox_position
  49. local entity_get_steam64 = entity.get_steam64
  50. local entity_get_bounding_box = entity.get_bounding_box
  51. local entity_is_alive = entity.is_alive
  52. local entity_is_dormant = entity.is_dormant
  53.  
  54. local ui_new_checkbox = ui.new_checkbox
  55. local ui_new_slider = ui.new_slider
  56. local ui_new_combobox = ui.new_combobox
  57. local ui_new_multiselect = ui.new_multiselect
  58. local ui_new_hotkey = ui.new_hotkey
  59. local ui_new_button = ui.new_button
  60. local ui_new_color_picker = ui.new_color_picker
  61. local ui_reference = ui.reference
  62. local ui_set = ui.set
  63. local ui_get = ui.get
  64. local ui_set_callback = ui.set_callback
  65. local ui_set_visible = ui.set_visible
  66. local ui_is_menu_open = ui.is_menu_open
  67.  
  68. local math_floor = math.floor
  69. local math_random = math.random
  70. local math_sqrt = math.sqrt
  71. local table_insert = table.insert
  72. local table_remove = table.remove
  73. local table_size = table.getn
  74. local table_sort = table.sort
  75. local string_format = string.format
  76. local string_length = string.len
  77. local string_reverse = string.reverse
  78. local string_sub = string.sub
  79.  
  80. -- Key value table for holding preset clan tags
  81. local clantag = {
  82.  
  83. ["Skeet"] = "skeet.cc",
  84. ["Gamer"] = "Gamer",
  85. ["Red Valve Clantag"] = " \x01\x0B\x02[VALV\xE1\xB4\xB1]\x01",
  86. ["Red Admin Clantag"] = " \x0B\x02ADMIN:\x01",
  87.  
  88. }
  89.  
  90. -- Function for collecting the keys for the clantag combobox
  91. local function getMenuItems()
  92.  
  93. local names = {}
  94.  
  95. for k, v in pairs(clantag) do
  96.  
  97. names[#names + 1] = k
  98.  
  99. end
  100.  
  101. table_sort(names)
  102. table_insert(names, 1, "Disabled")
  103. table_insert(names, "Custom")
  104.  
  105. return names
  106.  
  107. end
  108.  
  109. -- Menu
  110. local menu = {
  111.  
  112. enabled = ui_new_checkbox("MISC", "Miscellaneous", "Clantag changer"),
  113. clantags = ui_new_combobox("MISC", "Miscellaneous", "Clan tags", getMenuItems()),
  114. animated = ui_new_checkbox("MISC", "Miscellaneous", "Animated tag"),
  115. style = ui_new_combobox("MISC", "Miscellaneous", "Animation style", "Default", "Reverse"),
  116. speed = ui_new_slider("MISC", "Miscellaneous", "Animation speed", 0, 100, 30, true, "%", 1)
  117.  
  118. }
  119.  
  120. -- Variables
  121. local sClanTag
  122. local bSendPacket
  123. local bStaticStatus
  124. local iClanTagIndex
  125. local iClanTagReverseIndex
  126. local iClantTagPreviousIndex
  127. local iTagLength
  128.  
  129. -- Function for handling the menu
  130. local function handleMenu()
  131.  
  132. if ui_get(menu.enabled) then
  133.  
  134. ui_set_visible(menu.clantags, true)
  135. ui_set_visible(menu.animated, true)
  136.  
  137. if ui_get(menu.animated) then
  138.  
  139. ui_set_visible(menu.style, true)
  140. ui_set_visible(menu.speed, true)
  141.  
  142. else
  143.  
  144. ui_set_visible(menu.style, false)
  145. ui_set_visible(menu.speed, false)
  146.  
  147. end
  148.  
  149. else
  150.  
  151. client_set_clan_tag("\0")
  152. ui_set_visible(menu.clantags, false)
  153. ui_set_visible(menu.animated, false)
  154. ui_set_visible(menu.style, false)
  155. ui_set_visible(menu.speed, false)
  156.  
  157. end
  158.  
  159. end
  160.  
  161. handleMenu()
  162. ui_set_callback(menu.enabled, handleMenu)
  163. ui_set_callback(menu.animated, handleMenu)
  164.  
  165. -- Run command event
  166. client_set_event_callback("run_command", function(e)
  167.  
  168. if not ui_get(menu.enabled) then
  169.  
  170. return
  171.  
  172. end
  173.  
  174. -- Checks to see if packets are being sent, and setting the value of bSendPacket
  175. if e.chokedcommands == 0 then
  176.  
  177. bSendPacket = false
  178.  
  179. else
  180.  
  181. bSendPacket = true
  182.  
  183. end
  184.  
  185. end)
  186.  
  187. -- Function for updated clantag information
  188. local function handleClanTags()
  189.  
  190. if not ui_get(menu.enabled) or ui_get(menu.clantags) == "Disabled" then
  191.  
  192. -- Disabling the clantag if it's set to "Disabled"
  193. client_set_clan_tag("\0")
  194. return
  195.  
  196. end
  197.  
  198. -- Getting and settings the clantag string
  199. if ui_get(menu.clantags) == "Custom" then
  200.  
  201. if sClanTag ~= client_get_cvar("r_eyegloss") then
  202.  
  203. sClanTag = client_get_cvar("r_eyegloss")
  204. bStaticStatus = false
  205.  
  206. end
  207.  
  208. else
  209.  
  210. if sClanTag ~= clantag[ui_get(menu.clantags)] then
  211.  
  212. sClanTag = clantag[ui_get(menu.clantags)]
  213. bStaticStatus = false
  214.  
  215. end
  216.  
  217. end
  218.  
  219. -- Getting the tag length, and clamping it to 16
  220. iTagLength = math.min(16, string_length(sClanTag))
  221.  
  222. end
  223.  
  224. handleClanTags()
  225. ui_set_callback(menu.clantags, handleClanTags)
  226.  
  227. -- Animating function
  228. local function animateClanTag(style, index)
  229.  
  230. if not ui_get(menu.animated) then
  231.  
  232. return
  233.  
  234. end
  235.  
  236. if style == "Default" then
  237.  
  238. if index == 0 then
  239.  
  240. sClanTag = "\0"
  241. index = index + 1
  242.  
  243. end
  244.  
  245. client_set_clan_tag(string_sub(sClanTag, 1, index))
  246.  
  247. elseif style == "Reverse" then
  248.  
  249. if iClanTagReverseIndex <= iTagLength then
  250.  
  251. client_set_clan_tag(string_sub(sClanTag, 1, index))
  252.  
  253. else
  254.  
  255. if iTagLength - index == 0 then
  256.  
  257. sClanTag = "\0"
  258. index = iTagLength - 1
  259.  
  260. end
  261.  
  262. client_set_clan_tag(string_sub(sClanTag, 1, iTagLength - index))
  263.  
  264. end
  265.  
  266. end
  267.  
  268. end
  269.  
  270. -- Paint event (Used so clantag updates while dead)
  271. client_set_event_callback("paint", function(ctx)
  272.  
  273. if not ui_get(menu.enabled) or ui_get(menu.clantags) == "Disabled" then
  274.  
  275. return
  276.  
  277. end
  278.  
  279. -- Run command only runs while alive, if you're dead you're not sending packets.
  280. if not entity_is_alive(entity_get_local_player()) then
  281.  
  282. bSendPacket = false
  283.  
  284. end
  285.  
  286. -- Don't update animated tag if choking packets
  287. if bSendPacket then
  288.  
  289. return
  290.  
  291. end
  292.  
  293. -- Updating clantag information
  294. handleClanTags()
  295.  
  296. -- Checking if the clan tag is animated
  297. if not ui_get(menu.animated) then
  298.  
  299. -- Setting the static clantag once
  300. if not bStaticStatus then
  301.  
  302. client_set_clan_tag(sClanTag)
  303. bStaticStatus = true
  304.  
  305. end
  306.  
  307. else
  308.  
  309. -- Adding a few characters onto the length to add a slight pause when animating.
  310. iTagLength = iTagLength + 3
  311.  
  312. end
  313.  
  314. -- Getting the current clantag indexes
  315. iClanTagIndex = math_floor((globals_curtime() * (ui_get(menu.speed) / 10)) % iTagLength + 1)
  316. iClanTagReverseIndex = math_floor((globals_curtime() * (ui_get(menu.speed) / 10)) % (iTagLength * 2) + 1)
  317.  
  318. -- Checking if the last index is the same as the current index to avoid spamming
  319. if iClanTagIndex == iClantTagPreviousIndex then
  320.  
  321. return
  322.  
  323. end
  324.  
  325. -- Setting the previous Index
  326. iClantTagPreviousIndex = iClanTagIndex
  327.  
  328. -- Call animation function
  329. animateClanTag(ui_get(menu.style), iClanTagIndex)
  330.  
  331. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement