Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. --------------------------------------------------------------------------------
  2. -- Caching common functions
  3. --------------------------------------------------------------------------------
  4. local client_set_clan_tag, client_set_event_callback, client_system_time, entity_get_local_player, entity_get_player_resource, entity_get_prop, entity_is_alive, globals_curtime, math_floor, string_format, string_rep, table_insert, table_sort, ui_get, ui_new_checkbox, ui_new_combobox, ui_new_slider, ui_new_textbox, ui_set_callback, ui_set_visible, pairs = client.set_clan_tag, client.set_event_callback, client.system_time, entity.get_local_player, entity.get_player_resource, entity.get_prop, entity.is_alive, globals.curtime, math.floor, string.format, string.rep, table.insert, table.sort, ui.get, ui.new_checkbox, ui.new_combobox, ui.new_slider, ui.new_textbox, ui.set_callback, ui.set_visible, pairs
  5.  
  6. --------------------------------------------------------------------------------
  7. -- Utility functions
  8. --------------------------------------------------------------------------------
  9. local function collect_keys(tbl, custom)
  10. local keys = {}
  11. for k in pairs(tbl) do
  12. keys[#keys + 1] = k
  13. end
  14. table_sort(keys)
  15. if custom then
  16. table_insert(keys, 1, "Disabled")
  17. table_insert(keys, "Custom")
  18. end
  19. return keys
  20. end
  21.  
  22. --------------------------------------------------------------------------------
  23. -- Constants and variables
  24. --------------------------------------------------------------------------------
  25. local tags = {
  26. ["Toeaim"] = "toeaim.gov",
  27. ["Correct"] = "correct",
  28. ["Blaster"] = "nnblaster",
  29. ["Opulence"] = "opulence.cc",
  30. ["Nixware"] = "nixware.cc",
  31. ["Degadant"] = "degada.nt"
  32. }
  33.  
  34. local tag = ""
  35. local tag_index = 0
  36. local tag_length = 0
  37. local tag_reverse = 0
  38. local tag_last_index = 0
  39.  
  40. local commands = 0
  41.  
  42. --------------------------------------------------------------------------------
  43. -- Clan tag animations
  44. --------------------------------------------------------------------------------
  45. local function static()
  46. if tag == "Disabled" then
  47. return
  48. end
  49. local local_player = entity_get_local_player()
  50. local current_tag = entity_get_prop(entity_get_player_resource(), "m_szClan", local_player)
  51. if tag:len() == 0 and current_tag:len() ~= 0 then
  52. client_set_clan_tag("\0")
  53. elseif current_tag ~= tag then
  54. client_set_clan_tag(tag)
  55. end
  56. end
  57.  
  58. local function time()
  59. local h, m, s = client_system_time()
  60. local time_tag = string_format("%d:%02d:%02d", h, m, s)
  61. client_set_clan_tag(time_tag)
  62. end
  63.  
  64. local function default()
  65. if tag_index == tag_last_index then
  66. return
  67. end
  68. client_set_clan_tag(tag_index == 0 and "\0" or tag:sub(1, tag_index))
  69. end
  70.  
  71. local function reverse()
  72. if tag_index == tag_last_index then
  73. return
  74. end
  75. if tag_reverse <= tag_length then
  76. client_set_clan_tag(tag:sub(1, tag_index))
  77. else
  78. client_set_clan_tag(tag_length - tag_index == 0 and "\0" or tag:sub(1, tag_length - tag_index))
  79. end
  80. end
  81.  
  82. local function loop()
  83. if tag_index == tag_last_index then
  84. return
  85. end
  86. local result = ""
  87. local loop_tag = tag
  88. for i=1, tag_index do
  89. loop_tag = loop_tag .. loop_tag:sub(1, 1)
  90. loop_tag = loop_tag:sub(2, loop_tag:len())
  91. end
  92. client_set_clan_tag(loop_tag)
  93. end
  94.  
  95. local animations = {
  96. ["Static"] = static,
  97. ["Time"] = time,
  98. ["Default"] = default,
  99. ["Reverse"] = reverse,
  100. ["Classic"] = loop,
  101. ["Loop"] = loop,
  102. }
  103.  
  104. --------------------------------------------------------------------------------
  105. -- Menu
  106. --------------------------------------------------------------------------------
  107. local menu = {
  108. enabled = ui_new_checkbox("LUA", "B", "Clan tag changer"),
  109. tags = ui_new_combobox("LUA", "B", "Tags", collect_keys(tags, true)),
  110. text = ui_new_textbox("LUA", "B", "Text"),
  111. styles = ui_new_combobox("LUA", "B", "Animation", collect_keys(animations, false)),
  112. speed = ui_new_slider("LUA", "B", "Speed", 0, 100, 30, true, "%")
  113. }
  114.  
  115. local function handle_menu()
  116. local state = ui_get(menu.enabled)
  117. local menu_tag = ui_get(menu.tags)
  118. ui_set_visible(menu.tags, state)
  119. ui_set_visible(menu.styles, state)
  120. ui_set_visible(menu.speed, state)
  121. ui_set_visible(menu.text, state and menu_tag == "Custom")
  122. if not state then
  123. client_set_clan_tag("\0")
  124. end
  125. end
  126.  
  127. handle_menu()
  128. ui_set_callback(menu.enabled, handle_menu)
  129. ui_set_callback(menu.tags, handle_menu)
  130.  
  131. --------------------------------------------------------------------------------
  132. -- Game event handling
  133. --------------------------------------------------------------------------------
  134. local function net_update_end()
  135. if not ui_get(menu.enabled) then
  136. return
  137. end
  138. local local_player = entity_get_local_player()
  139. local menu_tag = ui_get(menu.tags)
  140. local tag_style = ui_get(menu.styles)
  141. local update_tag = commands == 0 or entity_is_alive(local_player) == false
  142. if menu_tag == "Disabled" then
  143. return
  144. end
  145. tag = menu_tag == "Custom" and ui_get(menu.text) or tags[menu_tag]
  146. tag = tag_style == "Loop" and tag .. " " or tag
  147. tag = tag_style == "Classic" and tag .. string_rep(" ", math_floor(tag:len() * 2)) or tag
  148. tag_length = tag:len()
  149. tag_index = math_floor((globals_curtime() * ui_get(menu.speed) / 10) % tag_length + 1)
  150. tag_reverse = math_floor((globals_curtime() * ui_get(menu.speed) / 10) % (tag_length * 2) + 1)
  151. if not update_tag then
  152. return
  153. end
  154. local animation = animations[tag_style]
  155. animation()
  156. tag_last_index = tag_index
  157. end
  158.  
  159. local function run_command(cmd)
  160. if not ui_get(menu.enabled) then
  161. return
  162. end
  163. commands = cmd.chokedcommands
  164. end
  165.  
  166. local function shutdown()
  167. client_set_clan_tag("\0")
  168. end
  169.  
  170. client_set_event_callback("net_update_end", net_update_end)
  171. client_set_event_callback("run_command", run_command)
  172. client_set_event_callback("shutdown", shutdown)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement