Figure this out later

This commit is contained in:
Ayane Satomi 2022-07-31 13:10:35 +08:00
parent 4885ff92a4
commit 19b8862d1b
No known key found for this signature in database
GPG key ID: 431E3C36BEBE204B

View file

@ -1,11 +1,10 @@
--@name Test-Serverinfo
--@author Minori
--@server
--@shared
--[[
This table contains the server metadata that is not usually need to be updated.
So it's fine to initialize them like this immediately.
TODO: Why is serverFrameTime nil? I don't get it.
This grabs the basic server information we can print later on
This table doesn't need to be updated much so we can initialize this immediately.
]]
local serverMetadata = {
serverName = game.getHostname(),
@ -13,9 +12,31 @@ local serverMetadata = {
maxPlayers = game.getMaxPlayers()
}
--[[
This keeps track of who is lagging the server, for visualization purposes.
The format would be the player's name and their Lag Point (LP) which is calculated based on info
we can publicly access in starfall.
]]
local serverBaddies = {}
cTime = os.date()
sTime = os.date()
if SERVER then
-- curTime is already initialized, we just need to update it per tick.
hook.add("think", "serverTimeTick", function()
sTime = os.date()
end)
end
if CLIENT then
hook.add("think", "clientTimeTick", function()
cTime = os.date()
end)
hook.add("render", "metadataRenderMain", function()
render.setColor(Color(255, 0, 0, 255))
render.drawText(10, 10, "Server Name: " .. serverMetadata.serverName)
render.drawText(10, 30, "Map: " .. serverMetadata.map)
render.drawText(10, 50, "Client Time: " .. cTime)
render.drawText(10, 70, "Server Time: " .. sTime)
end)
hook.add("ComponentUnlinked", "unlink_evt", function()
hook.remove("think", "curTimeMutator")
hook.remove("render", "metadataRenderMain")
end)
end