This commit is contained in:
lifestorm
2024-08-04 23:54:45 +03:00
parent 8064ba84d8
commit 6a58f406b1
7522 changed files with 4011896 additions and 15 deletions

View File

@@ -0,0 +1,44 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
-- Checks the newest version
if SERVER then
-- Checks the workshop page for version number.
local function RunCheck()
http.Fetch(StormFox2.WorkShopURL, function(code)
local lV = tonumber(string.match(code, "Version:(.-)<"))
if not lV then return end -- Unable to locate last version
if StormFox2.Version >= lV then return end -- Up to date
StormFox2.Msg("Version " .. lV .. " is out!")
StormFox2.Network.Set("stormfox_newv", lV)
cookie.Set("sf_nextv", lV)
end)
end
local function RunLogic()
-- Check if a newer version is out
local lV = cookie.GetNumber("sf_nextv", StormFox2.Version)
if cookie.GetNumber("sf_nextvcheck", 0) > os.time() then
if lV > StormFox2.Version then
StormFox2.Msg("Version " .. lV .. " is out!")
StormFox2.Network.Set("stormfox_newv", lV)
end
else
RunCheck()
cookie.Set("sf_nextvcheck", os.time() + 129600) -- Check in 1½ day
end
end
hook.Add("stormfox2.preinit", "stormfox2.checkversion", RunLogic)
end
-- Will return a version-number, if a new version is detected
---@return number
function StormFox2.NewVersion()
return StormFox2.Data.Get("stormfox_newv")
end