Initial Commit
This commit is contained in:
22
game-stats.lua
Normal file
22
game-stats.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
---Sends all mod infos for the current game, should only be called on the first load of the map since mods don't change during runtime
|
||||
function GetMods()
|
||||
local mods = script.active_mods
|
||||
local modstring = "---mod-info---\n"
|
||||
for k,v in pairs(mods) do
|
||||
modstring = modstring .. ("mod-info:%s:%s\n"):format(k,v)
|
||||
|
||||
end
|
||||
helpers.send_udp(52555, modstring,1)
|
||||
end
|
||||
|
||||
---Concats all player online times into a single string
|
||||
---Takes all players that ever visited the server into account
|
||||
---@return string
|
||||
function GetPlayerTime()
|
||||
local timeParts = {}
|
||||
timeParts[#timeParts+1] = "---player-times---\n"
|
||||
for _,player in pairs(game.players) do
|
||||
timeParts[#timeParts+1] = ("player-time:%s:%d:%d"):format(player.name, player.index, player.online_time)
|
||||
end
|
||||
return table.concat(timeParts, "\n")
|
||||
end
|
||||
Reference in New Issue
Block a user