stats.lua

main 58 lines · 1 KB Raw
Alex Alex Commit Client Upload Part 2 19/10/2026 00:06
1ui = nil
2updateEvent = nil
3
4function init()
5 ui = g_ui.loadUI('stats', modules.game_interface.getMapPanel())
6
7 if not modules.client_options.getOption("showPing") then
8 ui.fps:hide()
9 end
10 if not modules.client_options.getOption("showFps") then
11 ui.ping:hide()
12 end
13
14 updateEvent = scheduleEvent(update, 200)
15end
16
17function terminate()
18 removeEvent(updateEvent)
19end
20
21function update()
22 updateEvent = scheduleEvent(update, 500)
23 if ui:isHidden() then return end
24
25 text = 'FPS: ' .. g_app.getFps()
26 ui.fps:setText(text)
27
28 local ping = g_game.getPing()
29 if g_proxy and g_proxy.getPing() > 0 then
30 ping = g_proxy.getPing()
31 end
32
33 local text = 'Ping: '
34 local color
35 if ping < 0 then
36 text = text .. "??"
37 color = 'yellow'
38 else
39 text = text .. ping .. ' ms'
40 if ping >= 500 then
41 color = 'red'
42 elseif ping >= 250 then
43 color = 'yellow'
44 else
45 color = 'green'
46 end
47 end
48 ui.ping:setText(text)
49 ui.ping:setColor(color)
50end
51
52function show()
53 ui:setVisible(true)
54end
55
56function hide()
57 ui:setVisible(false)
58end
Top