Skip to content

Instantly share code, notes, and snippets.

@MrGrootx
Created July 30, 2024 01:56
Show Gist options
  • Select an option

  • Save MrGrootx/ae0a7c52a8256d3df3852a13ca447f40 to your computer and use it in GitHub Desktop.

Select an option

Save MrGrootx/ae0a7c52a8256d3df3852a13ca447f40 to your computer and use it in GitHub Desktop.
check fivem resource update
local function logMessage(_type, message)
local color = _type == 'success' and '^2' or '^1'
print(('^8[GD3V]%s %s^7'):format(color, message))
end
local function checkMenuVersion()
PerformHttpRequest('https://raw.githubusercontent.com/MrGrootx/g-updates/master/g-ownable-job-vehicle.txt',
function(err, text, headers)
if err ~= 200 then
logMessage('error', 'Unable to run a version check. Error: ' .. err)
return
end
local currentVersion = GetResourceMetadata(GetCurrentResourceName(), 'version', 0)
if not currentVersion then
logMessage('error', 'Unable to get current resource version.')
return
end
text = text:gsub("^%s*(.-)%s*$", "%1")
print(('^8[GD3V]^4 Current Version: %s^7'):format(currentVersion))
logMessage('success', ('Latest Version: %s'):format(text))
if text:gsub("%s+", "") == currentVersion:gsub("%s+", "") then
logMessage('success', 'You are running the latest version.')
else
logMessage('error',
('You are running an outdated version. Please update to version %s'):format(text))
end
end)
end
checkMenuVersion()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment