add supress_updates variable to config

This new `fxmanifest.lua` variable (when true) will stop checking for script updates

People REALLY dont like being told when somethings fixed.

This will stop the update notifications for both `jim_bridge` and the script that loads it.
This commit is contained in:
Jim Shield
2025-08-27 19:40:11 +01:00
parent eafa881cf8
commit 315634c173
3 changed files with 153 additions and 130 deletions

View File

@@ -1,67 +1,78 @@
local function parseVersion(version) local function readBoolMeta(key, default)
local parts = {} local val = GetResourceMetadata(GetCurrentResourceName(), key, 0)
for num in version:gmatch("%d+") do if not val then return default end
table.insert(parts, tonumber(num)) val = tostring(val):lower()
end return (val == 'true' or val == '1' or val == 'yes' or val == 'on')
return parts
end end
local function compareVersions(current, newest) local SUPPRESS_UPDATES = readBoolMeta('suppress_updates', false)
local currentParts = parseVersion(current)
local newestParts = parseVersion(newest) if not SUPPRESS_UPDATES then
for i = 1, math.max(#currentParts, #newestParts) do local function parseVersion(version)
local c = currentParts[i] or 0 local parts = {}
local n = newestParts[i] or 0 for num in version:gmatch("%d+") do
if c < n then return -1 table.insert(parts, tonumber(num))
elseif c > n then return 1 end end
return parts
end end
return 0 -- equal
end
function CheckBridgeVersion() local function compareVersions(current, newest)
if IsDuplicityVersion() then local currentParts = parseVersion(current)
CreateThread(function() local newestParts = parseVersion(newest)
Wait(4000) for i = 1, math.max(#currentParts, #newestParts) do
local currentVersionRaw = GetResourceMetadata("jim_bridge", 'version') local c = currentParts[i] or 0
--PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/test.txt', function(err, body, headers) local n = newestParts[i] or 0
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/master/version.txt', function(err, body, headers) if c < n then return -1
if not body then elseif c > n then return 1 end
print("^1Unable to run version check for ^7'^3jim_bridge^7' (^3"..currentVersionRaw.."^7)") end
return return 0 -- equal
end end
local lines = {} function CheckBridgeVersion()
for line in body:gmatch("[^\r\n]+") do if IsDuplicityVersion() then
table.insert(lines, line) CreateThread(function()
end Wait(4000)
local currentVersionRaw = GetResourceMetadata("jim_bridge", 'version')
local newestVersionRaw = lines[1] or "0.0.0" --PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/test.txt', function(err, body, headers)
local changelog = {} PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/master/version.txt', function(err, body, headers)
for i = 2, #lines do if not body then
table.insert(changelog, lines[i]) print("^1Unable to run version check for ^7'^3jim_bridge^7' (^3"..currentVersionRaw.."^7)")
end return
local compareResult = compareVersions(currentVersionRaw, newestVersionRaw)
if compareResult == 0 then
print("^7'^3jim_bridge^7' - ^2You are running the latest version^7. ^7(^3"..currentVersionRaw.."^7)")
elseif compareResult < 0 then
print("^1----------------------------------------------------------------------^7")
print("^7'^3jim_bridge^7' - ^1You are running an outdated version^7! ^7(^3"..currentVersionRaw.."^7 → ^3"..newestVersionRaw.."^7)")
for _, line in ipairs(changelog) do
print((line:find("http") and "^7" or "^5")..line)
end end
print("^1----------------------------------------------------------------------^7")
SetTimeout(3600000, function() local lines = {}
CheckBridgeVersion() for line in body:gmatch("[^\r\n]+") do
end) table.insert(lines, line)
else end
print("^7'^3jim_bridge^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersionRaw.."^7)")
end local newestVersionRaw = lines[1] or "0.0.0"
local changelog = {}
for i = 2, #lines do
table.insert(changelog, lines[i])
end
local compareResult = compareVersions(currentVersionRaw, newestVersionRaw)
if compareResult == 0 then
print("^7'^3jim_bridge^7' - ^2You are running the latest version^7. ^7(^3"..currentVersionRaw.."^7)")
elseif compareResult < 0 then
print("^1----------------------------------------------------------------------^7")
print("^7'^3jim_bridge^7' - ^1You are running an outdated version^7! ^7(^3"..currentVersionRaw.."^7 → ^3"..newestVersionRaw.."^7)")
for _, line in ipairs(changelog) do
print((line:find("http") and "^7" or "^5")..line)
end
print("^1----------------------------------------------------------------------^7")
SetTimeout(3600000, function()
CheckBridgeVersion()
end)
else
print("^7'^3jim_bridge^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersionRaw.."^7)")
end
end)
end) end)
end) end
end end
end
CheckBridgeVersion() CheckBridgeVersion()
end

View File

@@ -7,7 +7,6 @@ rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aw
games { 'gta5', 'rdr3' } games { 'gta5', 'rdr3' }
lua54 'yes' lua54 'yes'
files { files {
'starter.lua', 'starter.lua',
'shared/*.lua', 'shared/*.lua',
@@ -24,4 +23,6 @@ server_scripts {
client_scripts { client_scripts {
'clientFrameworkCache.lua', 'clientFrameworkCache.lua',
'ui_modules/*.lua', 'ui_modules/*.lua',
} }
suppress_updates 'true' -- set to 'true' to disable update pings

View File

@@ -1,100 +1,111 @@
function parseVersion(version) local function readBoolMeta(key, default)
local parts = {} local val = GetResourceMetadata("jim_bridge", key, 0)
for num in version:gmatch("%d+") do if not val then return default end
table.insert(parts, tonumber(num)) val = tostring(val):lower()
return (val == 'true' or val == '1' or val == 'yes' or val == 'on')
end
local SUPPRESS_UPDATES = readBoolMeta('suppress_updates', false)
if not SUPPRESS_UPDATES then
function parseVersion(version)
local parts = {}
for num in version:gmatch("%d+") do
table.insert(parts, tonumber(num))
end
return parts
end end
return parts
end
function compareVersions(current, newest) function compareVersions(current, newest)
local currentParts = parseVersion(current) local currentParts = parseVersion(current)
local newestParts = parseVersion(newest) local newestParts = parseVersion(newest)
for i = 1, math.max(#currentParts, #newestParts) do for i = 1, math.max(#currentParts, #newestParts) do
local c = currentParts[i] or 0 local c = currentParts[i] or 0
local n = newestParts[i] or 0 local n = newestParts[i] or 0
if c < n then return -1 if c < n then return -1
elseif c > n then return 1 end elseif c > n then return 1 end
end
return 0
end end
return 0
end
function capitalize(str) function capitalize(str)
return (str:gsub("^%l", string.upper):gsub("%-%l", function(letter) return "-" .. string.upper(letter:sub(2)) end)) return (str:gsub("^%l", string.upper):gsub("%-%l", function(letter) return "-" .. string.upper(letter:sub(2)) end))
end end
local scriptName = ("^2"..capitalize(getScript()):gsub("%-", "^7-^2"):gsub("%_", "^7_^2")) or "" local scriptName = ("^2"..capitalize(getScript()):gsub("%-", "^7-^2"):gsub("%_", "^7_^2")) or ""
local scriptVersion = ("^5"..GetResourceMetadata(getScript(), 'version', nil):gsub("%.", "^7.^5")) or "" local scriptVersion = ("^5"..GetResourceMetadata(getScript(), 'version', nil):gsub("%.", "^7.^5")) or ""
local scriptDescription = ("^2"..GetResourceMetadata(getScript(), 'description', nil)) or "" local scriptDescription = ("^2"..GetResourceMetadata(getScript(), 'description', nil)) or ""
local scriptAuthor = ("^2by ^4"..GetResourceMetadata(getScript(), 'author', nil):gsub("%and", "^7and^4")) or "" local scriptAuthor = ("^2by ^4"..GetResourceMetadata(getScript(), 'author', nil):gsub("%and", "^7and^4")) or ""
print(scriptName.." ^7v"..scriptVersion.."^7 - "..scriptDescription.." "..scriptAuthor.."^7") print(scriptName.." ^7v"..scriptVersion.."^7 - "..scriptDescription.." "..scriptAuthor.."^7")
function CheckVersion() function CheckVersion()
if isServer() and GetResourceMetadata(getScript(), 'author', nil) == "Jimathy" then if isServer() and GetResourceMetadata(getScript(), 'author', nil) == "Jimathy" then
CreateThread(function() CreateThread(function()
Wait(4000) Wait(4000)
local script = getScript() local script = getScript()
local currentVersionRaw = GetResourceMetadata(script, 'version') local currentVersionRaw = GetResourceMetadata(script, 'version')
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/'..script..'.txt', function(err, newestVersionRaw, headers) PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/'..script..'.txt', function(err, newestVersionRaw, headers)
if not newestVersionRaw then if not newestVersionRaw then
-- fallback -- fallback
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..script..'/master/version.txt', function(err, fallbackVersionRaw, headers) PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..script..'/master/version.txt', function(err, fallbackVersionRaw, headers)
if not fallbackVersionRaw then if not fallbackVersionRaw then
print("^1Currently unable to run a version check for ^7'^3"..script.."^7' (^3"..currentVersionRaw.."^7)") print("^1Currently unable to run a version check for ^7'^3"..script.."^7' (^3"..currentVersionRaw.."^7)")
return return
end end
local lines = {}
for line in fallbackVersionRaw:gmatch("[^\r\n]+") do table.insert(lines, line) end
local fallbackVersion = (lines[1] or "0.0.0"):gsub("v", "")
local changelog = {}
for i = 2, #lines do table.insert(changelog, lines[i]) end
local compareResult = compareVersions(currentVersionRaw, fallbackVersion)
if compareResult == 0 then
print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)")
elseif compareResult < 0 then
print("^1----------------------------------------------------------------------^7")
print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..fallbackVersion.."^7)")
if #changelog > 0 then
for _, line in ipairs(changelog) do
print((line:find("http") and "^7" or "^5")..line)
end
end
print("^1----------------------------------------------------------------------^7")
SetTimeout(1200000, function() CheckVersion() end)
else
print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..fallbackVersion.."^7)")
end
end)
else
local lines = {} local lines = {}
for line in fallbackVersionRaw:gmatch("[^\r\n]+") do table.insert(lines, line) end for line in newestVersionRaw:gmatch("[^\r\n]+") do table.insert(lines, line) end
local fallbackVersion = (lines[1] or "0.0.0"):gsub("v", "") local newestVersion = (lines[1] or "0.0.0"):gsub("v", "")
local changelog = {} local changelog = {}
for i = 2, #lines do table.insert(changelog, lines[i]) end for i = 2, #lines do table.insert(changelog, lines[i]) end
local compareResult = compareVersions(currentVersionRaw, fallbackVersion) local compareResult = compareVersions(currentVersionRaw, newestVersion)
if compareResult == 0 then if compareResult == 0 then
print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)") print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)")
elseif compareResult < 0 then elseif compareResult < 0 then
print("^1----------------------------------------------------------------------^7") print("^1----------------------------------------------------------------------^7")
print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..fallbackVersion.."^7)") print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..newestVersion.."^7)")
if #changelog > 0 then if #changelog > 0 then
for _, line in ipairs(changelog) do for _, line in ipairs(changelog) do
print((line:find("http") and "^7" or "^5")..line) print((line:find("http") and "^7" or "^5")..line)
end end
end end
print("^1----------------------------------------------------------------------^7") print("^1----------------------------------------------------------------------^7")
SetTimeout(1200000, function() CheckVersion() end) SetTimeout(3600000, function() CheckVersion() end)
else else
print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..fallbackVersion.."^7)") print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersion.."^7)")
end end
end)
else
local lines = {}
for line in newestVersionRaw:gmatch("[^\r\n]+") do table.insert(lines, line) end
local newestVersion = (lines[1] or "0.0.0"):gsub("v", "")
local changelog = {}
for i = 2, #lines do table.insert(changelog, lines[i]) end
local compareResult = compareVersions(currentVersionRaw, newestVersion)
if compareResult == 0 then
print("^7'^3"..script.."^7' - ^2You are running the latest version^7. (^3"..currentVersionRaw.."^7)")
elseif compareResult < 0 then
print("^1----------------------------------------------------------------------^7")
print("^7'^3"..script.."^7' - ^1You are currently running an outdated version^7! (^3"..currentVersionRaw.."^7 → ^3"..newestVersion.."^7)")
if #changelog > 0 then
for _, line in ipairs(changelog) do
print((line:find("http") and "^7" or "^5")..line)
end
end
print("^1----------------------------------------------------------------------^7")
SetTimeout(3600000, function() CheckVersion() end)
else
print("^7'^3"..script.."^7' - ^5You are running a newer version ^7(^3"..currentVersionRaw.."^7 ← ^3"..newestVersion.."^7)")
end end
end end)
end) end)
end) end
end end
end
CheckVersion() CheckVersion()
end