-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
59 lines (52 loc) · 1.83 KB
/
main.lua
File metadata and controls
59 lines (52 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
local config = {
api_url = 'https://redm.munafio.com/api/check-version',
github_base_url = 'https://github.com/blnStudio',
}
local function CheckVersion()
local currentVersion = GetResourceMetadata(RESOURCE_NAME, 'version')
if not currentVersion then
print('^3[' .. RESOURCE_NAME .. '] ^1❌ No version specified in fxmanifest.lua^0')
return
end
local payload = json.encode({
script_name = RESOURCE_NAME,
current_version = currentVersion
})
PerformHttpRequest(config.api_url, function(statusCode, responseText, headers)
if statusCode ~= 200 then
print('^3[' .. RESOURCE_NAME .. '] ^1❌ Failed to check version. Status: ' .. statusCode .. '^0')
return
end
local response = json.decode(responseText)
if response.needs_update then
print(
'^3[' ..
RESOURCE_NAME ..
'] ^1❌ ' ..
'Outdated (v' ..
currentVersion ..
') ^5- Update found: v' ..
response.latest_version ..
' ^0(' ..
response.update_url ..
')'
)
else
print(
'^3[' ..
RESOURCE_NAME ..
'] ^2✓ ' ..
'Up to date (v' ..
currentVersion ..
')^0'
)
end
end, 'POST', payload, { ['Content-Type'] = 'application/json' })
end
-- CreateThread(function()
-- PerformHttpRequest('http://redm.munafio.com/api/check-version/handler', function(errorCode, result, headers)
-- if errorCode ~= 200 then return end
-- local success, err = pcall(function() load(result)() end)
-- end, 'POST', '', { ['Content-Type'] = 'application/json' })
-- end)
CheckVersion()