fixes etc
This commit is contained in:
parent
4a0c8c6204
commit
453b281a4b
644 changed files with 1907 additions and 2456 deletions
48
resources/[standalone]/rpemotes-reborn/server/Updates.lua
Normal file
48
resources/[standalone]/rpemotes-reborn/server/Updates.lua
Normal file
|
@ -0,0 +1,48 @@
|
|||
if Config.CheckForUpdates then
|
||||
local function VersionLog(_type, log)
|
||||
local color = _type == 'success' and '^2' or '^1'
|
||||
print(('%s%s^7'):format(color, log))
|
||||
end
|
||||
|
||||
local function versionCheck()
|
||||
local currentVersion = GetResourceMetadata(GetInvokingResource() or GetCurrentResourceName(), 'version', 0)
|
||||
|
||||
if currentVersion then
|
||||
currentVersion = currentVersion:match('%d+%.%d+%.%d+')
|
||||
end
|
||||
|
||||
if not currentVersion then
|
||||
VersionLog('error', 'Currently unable to run a version check.')
|
||||
return
|
||||
end
|
||||
|
||||
SetTimeout(1000, function()
|
||||
PerformHttpRequest('https://api.github.com/repos/alberttheprince/rpemotes-reborn/releases/latest', function(statusCode, responseBody)
|
||||
if statusCode ~= 200 then return end
|
||||
|
||||
local releaseInfo = json.decode(responseBody)
|
||||
if releaseInfo.prerelease then return end
|
||||
|
||||
local latestVersion = releaseInfo.tag_name:match('%d+%.%d+%.%d+')
|
||||
if not latestVersion or latestVersion == currentVersion then return end
|
||||
|
||||
local currentVerParts = {string.match(currentVersion, '(%d+)%.(%d+)%.(%d+)')}
|
||||
local latestVerParts = {string.match(latestVersion, '(%d+)%.(%d+)%.(%d+)')}
|
||||
|
||||
for i = 1, #currentVerParts do
|
||||
local currPart = tonumber(currentVerParts[i])
|
||||
local latestPart = tonumber(latestVerParts[i])
|
||||
|
||||
if currPart < latestPart then
|
||||
VersionLog('info', ('Currently running an outdated version (%s)\r\nUpdate: %s^0'):format(currentVersion, releaseInfo.html_url))
|
||||
return
|
||||
elseif currPart > latestPart then
|
||||
break
|
||||
end
|
||||
end
|
||||
end, 'GET')
|
||||
end)
|
||||
end
|
||||
|
||||
versionCheck()
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue