MaxproGlitcher

Systeme Graphique Max .lua

Oct 29th, 2024
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. local uis = game:GetService("UserInputService")
  2. local viewportSize = workspace.CurrentCamera.ViewportSize
  3.  
  4. local graph = {}
  5. graph.elapsed = 0
  6. graph.heartBeat = game:GetService("RunService").Heartbeat
  7. graph.pingStatsItem = game:GetService("Stats").Network.ServerStatsItem["Data Ping"]
  8. graph.maxPing = 200
  9. graph.size = Vector2.new(250, 200)
  10. graph.dragging = false
  11. graph.updateRate = 1
  12. graph.colorOffset = 0
  13.  
  14. -- Positions relatives (multipliées par la taille de l'écran)
  15. local relativeX, relativeY = 0.789, 0.910
  16. graph.defaultPosition = Vector2.new(viewportSize.X * relativeX, viewportSize.Y * relativeY)
  17.  
  18. graph.lines = {}
  19. for i = 1, 4 do
  20. local line = Drawing.new("Line")
  21. line.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
  22. line.Visible = true
  23. graph.lines[i] = line
  24. end
  25.  
  26. -- Utiliser la position par défaut relative
  27. graph.origin = graph.defaultPosition
  28.  
  29. graph.createMaxpro = function(dir)
  30. local line = Drawing.new("Line")
  31. line.Visible = true
  32. line.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
  33. line.From = graph.origin
  34. line.To = graph.origin + (dir == "x" and Vector2.new(graph.size.x, 0) or Vector2.new(0, -graph.size.y))
  35. return line
  36. end
  37.  
  38. graph.Maxpro = graph.createMaxpro("x")
  39. graph.MaxproGlitcher = graph.createMaxpro("y")
  40.  
  41. graph.text = Drawing.new("Text")
  42. graph.text.Text = "Ping: 0"
  43. graph.text.Position = graph.origin + graph.text.TextBounds
  44. graph.text.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
  45. graph.text.Visible = true
  46.  
  47. graph.points = {pings = {}}
  48.  
  49. graph.updateColors = function()
  50. graph.colorOffset = (graph.colorOffset + 0.01) % 1
  51. for i, line in ipairs(graph.lines) do
  52. line.Color = Color3.fromHSV((graph.colorOffset + i * 0.1) % 1, 1, 1)
  53. end
  54. graph.Maxpro.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
  55. graph.MaxproGlitcher.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
  56. graph.text.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
  57. end
  58.  
  59. graph.updateLines = function()
  60. graph.Maxpro.From = graph.origin
  61. graph.Maxpro.To = graph.origin + Vector2.new(graph.size.x, 0)
  62.  
  63. graph.MaxproGlitcher.From = graph.origin
  64. graph.MaxproGlitcher.To = graph.origin + Vector2.new(0, -graph.size.y)
  65.  
  66. for i = 1, #graph.points.pings - 1 do
  67. local curr = graph.points.pings[i]
  68. local after = graph.points.pings[i + 1]
  69.  
  70. if after then
  71. graph.lines[i].From = graph.origin + Vector2.new((graph.size.x / 4) * (i - 1), -graph.size.y * math.clamp(curr / graph.maxPing, 0, 1))
  72. graph.lines[i].To = graph.origin + Vector2.new((graph.size.x / 4) * i, -graph.size.y * math.clamp(after / graph.maxPing, 0, 1))
  73. end
  74. end
  75. end
  76.  
  77. setmetatable(graph.points, {
  78. __index = graph.points.pings,
  79. __newindex = function(t, k, v)
  80. if k > 5 then
  81. local removed = table.remove(t.pings, 1)
  82. if removed == graph.maxPing then
  83. graph.maxPing = 200
  84. end
  85. end
  86.  
  87. t.pings[#t.pings + 1] = v
  88.  
  89. if v > graph.maxPing then
  90. graph.maxPing = v
  91. end
  92.  
  93. graph.text.Text = "Ping: " .. math.round(v)
  94. end
  95. })
  96.  
  97. uis.InputBegan:connect(function(k)
  98. if k.UserInputType == Enum.UserInputType.MouseButton1 then
  99. local diff = Vector2.new(k.Position.x, k.Position.y) - graph.origin
  100. if diff.x > 0 and diff.x < graph.size.x and diff.y < 0 and diff.y > -(graph.size.y + 25) then
  101. graph.dragging = true
  102. end
  103. end
  104. end)
  105.  
  106. uis.InputChanged:connect(function(k)
  107. if k.UserInputType == Enum.UserInputType.MouseMovement and graph.dragging then
  108. if graph.lastMousePos then
  109. graph.origin += (Vector2.new(k.Position.x, k.Position.y) - graph.lastMousePos)
  110. graph.updateLines()
  111. graph.text.Position = graph.origin + graph.text.TextBounds
  112. end
  113.  
  114. graph.lastMousePos = Vector2.new(k.Position.x, k.Position.y)
  115. end
  116. end)
  117.  
  118. uis.InputEnded:connect(function(k)
  119. if k.UserInputType == Enum.UserInputType.MouseButton1 then
  120. local diff = Vector2.new(k.Position.x, k.Position.y) - graph.origin
  121. if diff.x > 0 and diff.x < graph.size.x and diff.y < 0 and diff.y > -(graph.size.y + 25) then
  122. graph.dragging = false
  123. graph.lastMousePos = nil
  124. end
  125. end
  126. end)
  127.  
  128. while true do
  129. local step = graph.heartBeat:wait()
  130. graph.elapsed += step
  131.  
  132. if graph.elapsed % graph.updateRate <= step then
  133. graph.points[#graph.points.pings + 1] = graph.pingStatsItem:GetValue()
  134. graph.updateLines()
  135. graph.updateColors()
  136. end
  137. end
  138.  
Advertisement
Add Comment
Please, Sign In to add comment