local localVersion = GetResourceMetadata(GetCurrentResourceName(), "version", 0) local resourceName = GetCurrentResourceName() local function splitString(str, sep) local parts = {} local pattern = string.format("([^%s]+)", sep or ":") str:gsub(pattern, function(part) parts[#parts + 1] = part end) return parts end string.split = splitString local function versionToNumber(versionStr) local parts = versionStr:split(".") local result = "" for i = 1, #parts do result = result .. parts[i] end return tonumber(result) end local function compareVersions(remoteVersion, descriptions) local remote = versionToNumber(remoteVersion) local local_ = versionToNumber(localVersion) return remote - local_, descriptions end if localVersion then local versionUrl = "https://raw.githubusercontent.com/quasar-scripts/version/main/" .. resourceName .. ".json" PerformHttpRequest(versionUrl, function(statusCode, responseBody, headers) if statusCode == 404 then print("^1API is not available. Unable to check the version.^0") return end if statusCode == 200 then local data = json.decode(responseBody) local remoteVersion = data.version local descriptions = data.descriptions local diff, changeLog = compareVersions(remoteVersion, descriptions) if diff == 0 then print("^2You are using the latest version of " .. resourceName .. "!^0") elseif diff > 0 then print("^3New version available for " .. resourceName .. "!^0") for _, change in pairs(changeLog) do print("^3- " .. change .. "^0") end print("^3You have version " .. localVersion .. ", upgrade to version " .. remoteVersion .. "!^0") else print("^1You are using a newer version of " .. resourceName .. " than the one available on GitHub.^0") end end end, "GET", "", {}, {}) else print("Unable to obtain the version of " .. resourceName .. ". Make sure it is defined in your fxmanifest.lua.") end