MaxproGlitcher

graphique ping

Aug 1st, 2022 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. game:GetService("StarterGui"):SetCore("SendNotification",{
  2. Title = "Connection Internet",
  3. Text = "Script a été executer",
  4. Icon = "rbxassetid://11823384169",
  5. Duration = 15
  6. })
  7.  
  8. local uis = game:GetService("UserInputService")
  9.  
  10. local graph = {}
  11. graph.elapsed = 0
  12. graph.heartBeat = game:GetService("RunService").Heartbeat
  13. graph.pingStatsItem = game:GetService("Stats").Network.ServerStatsItem["Data Ping"]
  14. graph.maxPing = 200 -- for scaling
  15. graph.size = Vector2.new(250, 200)
  16. graph.dragging = false
  17. graph.updateRate = 1
  18.  
  19. graph.lines = {}
  20.  
  21. for i=1,4 do
  22. local line = Drawing.new("Line")
  23. line.Color = Color3.fromRGB(0, 255, 0)
  24. line.Visible = true
  25. graph.lines[i] = line
  26. end
  27.  
  28. graph.origin = workspace.CurrentCamera.ViewportSize * Vector2.new(0.05, 0.25)
  29.  
  30. graph.createaxis = function(dir)
  31. local line = Drawing.new("Line")
  32. line.Visible = true
  33. line.Color = Color3.fromRGB(255, 255, 255)
  34. line.From = graph.origin
  35. line.To = graph.origin + (dir == "x" and Vector2.new(graph.size.x, 0) or Vector2.new(0, -graph.size.y))
  36. return line
  37. end
  38.  
  39. graph.xaxis = graph.createaxis("x")
  40. graph.yaxis = graph.createaxis("y")
  41.  
  42. graph.text = Drawing.new("Text")
  43. graph.text.Text = "Ping: 0"
  44. graph.text.Position = graph.origin + graph.text.TextBounds
  45. graph.text.Color = Color3.fromRGB(255, 255, 255)
  46. graph.text.Visible = true
  47.  
  48. graph.points = {pings = {}}
  49.  
  50. graph.updateLines = function()
  51. graph.xaxis.From = graph.origin
  52. graph.xaxis.To = graph.origin + Vector2.new(graph.size.x, 0)
  53.  
  54. graph.yaxis.From = graph.origin
  55. graph.yaxis.To = graph.origin + Vector2.new(0, -graph.size.y)
  56.  
  57. for i=1,#graph.points.pings-1 do
  58. local curr = graph.points.pings[i]
  59. local after = graph.points.pings[i + 1]
  60.  
  61. if after then
  62. graph.lines[i].From = graph.origin + Vector2.new((graph.size.x / 4) * (i - 1), -graph.size.y * math.clamp(curr / graph.maxPing, 0, 1))
  63.  
  64. local toDest = graph.origin + Vector2.new((graph.size.x / 4) * i, -graph.size.y * math.clamp(after / graph.maxPing, 0, 1))
  65.  
  66. if i == #graph.points.pings - 1 and not graph.dragging then
  67. for j=0,1,0.05 do
  68. graph.lines[i].To = graph.lines[i].From:lerp(toDest, j)
  69. graph.heartBeat:wait()
  70. end
  71. else
  72. graph.lines[i].To = toDest
  73. end
  74. end
  75. end
  76. end
  77.  
  78. setmetatable(graph.points, {
  79. __index = graph.points.pings,
  80. __newindex = function(t,k,v)
  81. if k > 5 then
  82. local removed = table.remove(t.pings, 1)
  83. if removed == graph.maxPing then
  84. graph.maxPing = 200
  85. end
  86. end
  87.  
  88. t.pings[#t.pings + 1] = v
  89.  
  90. if v > graph.maxPing then
  91. graph.maxPing = v
  92. end
  93.  
  94. graph.text.Text = "Ping: " .. math.round(v)
  95. end
  96. })
  97.  
  98. uis.InputBegan:connect(function(k)
  99. if k.UserInputType == Enum.UserInputType.MouseButton1 then
  100. local diff = Vector2.new(k.Position.x, k.Position.y) - graph.origin
  101. if diff.x > 0 and diff.x < graph.size.x and diff.y < 0 and diff.y > -(graph.size.y + 25) then
  102. graph.dragging = true
  103. end
  104. end
  105. end)
  106.  
  107. uis.InputChanged:connect(function(k)
  108. if k.UserInputType == Enum.UserInputType.MouseMovement and graph.dragging then
  109. if graph.lastMousePos then
  110. graph.origin += (Vector2.new(k.Position.x, k.Position.y) - graph.lastMousePos)
  111. graph.updateLines()
  112.  
  113. graph.text.Position = graph.origin + graph.text.TextBounds
  114. end
  115.  
  116. graph.lastMousePos = Vector2.new(k.Position.x, k.Position.y)
  117. end
  118. end)
  119.  
  120. uis.InputEnded:connect(function(k)
  121. if k.UserInputType == Enum.UserInputType.MouseButton1 then
  122. local diff = Vector2.new(k.Position.x, k.Position.y) - graph.origin
  123. if diff.x > 0 and diff.x < graph.size.x and diff.y < 0 and diff.y > -(graph.size.y + 25) then
  124. graph.dragging = false
  125. graph.lastMousePos = nil
  126. end
  127. end
  128. end)
  129.  
  130. while true do
  131. local step = graph.heartBeat:wait()
  132.  
  133. graph.elapsed += step
  134.  
  135. if graph.elapsed % graph.updateRate <= step then
  136. graph.points[#graph.points.pings + 1] = graph.pingStatsItem:GetValue()
  137.  
  138. graph.updateLines()
  139. end
  140. end
Advertisement
Add Comment
Please, Sign In to add comment