Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local uis = game:GetService("UserInputService")
- local viewportSize = workspace.CurrentCamera.ViewportSize
- local graph = {}
- graph.elapsed = 0
- graph.heartBeat = game:GetService("RunService").Heartbeat
- graph.pingStatsItem = game:GetService("Stats").Network.ServerStatsItem["Data Ping"]
- graph.maxPing = 200
- graph.size = Vector2.new(250, 200)
- graph.dragging = false
- graph.updateRate = 1
- graph.colorOffset = 0
- -- Positions relatives (multipliées par la taille de l'écran)
- local relativeX, relativeY = 0.789, 0.910
- graph.defaultPosition = Vector2.new(viewportSize.X * relativeX, viewportSize.Y * relativeY)
- graph.lines = {}
- for i = 1, 4 do
- local line = Drawing.new("Line")
- line.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
- line.Visible = true
- graph.lines[i] = line
- end
- -- Utiliser la position par défaut relative
- graph.origin = graph.defaultPosition
- graph.createMaxpro = function(dir)
- local line = Drawing.new("Line")
- line.Visible = true
- line.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
- line.From = graph.origin
- line.To = graph.origin + (dir == "x" and Vector2.new(graph.size.x, 0) or Vector2.new(0, -graph.size.y))
- return line
- end
- graph.Maxpro = graph.createMaxpro("x")
- graph.MaxproGlitcher = graph.createMaxpro("y")
- graph.text = Drawing.new("Text")
- graph.text.Text = "Ping: 0"
- graph.text.Position = graph.origin + graph.text.TextBounds
- graph.text.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
- graph.text.Visible = true
- graph.points = {pings = {}}
- graph.updateColors = function()
- graph.colorOffset = (graph.colorOffset + 0.01) % 1
- for i, line in ipairs(graph.lines) do
- line.Color = Color3.fromHSV((graph.colorOffset + i * 0.1) % 1, 1, 1)
- end
- graph.Maxpro.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
- graph.MaxproGlitcher.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
- graph.text.Color = Color3.fromHSV(graph.colorOffset, 1, 1)
- end
- graph.updateLines = function()
- graph.Maxpro.From = graph.origin
- graph.Maxpro.To = graph.origin + Vector2.new(graph.size.x, 0)
- graph.MaxproGlitcher.From = graph.origin
- graph.MaxproGlitcher.To = graph.origin + Vector2.new(0, -graph.size.y)
- for i = 1, #graph.points.pings - 1 do
- local curr = graph.points.pings[i]
- local after = graph.points.pings[i + 1]
- if after then
- graph.lines[i].From = graph.origin + Vector2.new((graph.size.x / 4) * (i - 1), -graph.size.y * math.clamp(curr / graph.maxPing, 0, 1))
- graph.lines[i].To = graph.origin + Vector2.new((graph.size.x / 4) * i, -graph.size.y * math.clamp(after / graph.maxPing, 0, 1))
- end
- end
- end
- setmetatable(graph.points, {
- __index = graph.points.pings,
- __newindex = function(t, k, v)
- if k > 5 then
- local removed = table.remove(t.pings, 1)
- if removed == graph.maxPing then
- graph.maxPing = 200
- end
- end
- t.pings[#t.pings + 1] = v
- if v > graph.maxPing then
- graph.maxPing = v
- end
- graph.text.Text = "Ping: " .. math.round(v)
- end
- })
- uis.InputBegan:connect(function(k)
- if k.UserInputType == Enum.UserInputType.MouseButton1 then
- local diff = Vector2.new(k.Position.x, k.Position.y) - graph.origin
- if diff.x > 0 and diff.x < graph.size.x and diff.y < 0 and diff.y > -(graph.size.y + 25) then
- graph.dragging = true
- end
- end
- end)
- uis.InputChanged:connect(function(k)
- if k.UserInputType == Enum.UserInputType.MouseMovement and graph.dragging then
- if graph.lastMousePos then
- graph.origin += (Vector2.new(k.Position.x, k.Position.y) - graph.lastMousePos)
- graph.updateLines()
- graph.text.Position = graph.origin + graph.text.TextBounds
- end
- graph.lastMousePos = Vector2.new(k.Position.x, k.Position.y)
- end
- end)
- uis.InputEnded:connect(function(k)
- if k.UserInputType == Enum.UserInputType.MouseButton1 then
- local diff = Vector2.new(k.Position.x, k.Position.y) - graph.origin
- if diff.x > 0 and diff.x < graph.size.x and diff.y < 0 and diff.y > -(graph.size.y + 25) then
- graph.dragging = false
- graph.lastMousePos = nil
- end
- end
- end)
- while true do
- local step = graph.heartBeat:wait()
- graph.elapsed += step
- if graph.elapsed % graph.updateRate <= step then
- graph.points[#graph.points.pings + 1] = graph.pingStatsItem:GetValue()
- graph.updateLines()
- graph.updateColors()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment