Skip to content

Commit 86c8b1a

Browse files
authored
Create main.lua
1 parent 4000b2d commit 86c8b1a

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

server/main.lua

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
AddEventHandler('onResourceStart', function(resource)
2+
if resource == GetCurrentResourceName() then
3+
zapsupdatee()
4+
5+
if resource == 'RedTrainer' then
6+
7+
else
8+
print("^1[ERROR] Please rename your resource to RedTrainer")
9+
end
10+
end
11+
end)
12+
13+
function zapsupdatee()
14+
local githubRawUrl = "https://raw.githubusercontent.com/Zaps6000/base/main/api.json"
15+
local resourceName = "RedTrainer"
16+
17+
PerformHttpRequest(githubRawUrl, function(statusCode, responseText, headers)
18+
if statusCode == 200 then
19+
local responseData = json.decode(responseText)
20+
21+
if responseData[resourceName] then
22+
local remoteVersion = responseData[resourceName].version
23+
local description = responseData[resourceName].description
24+
local changelog = responseData[resourceName].changelog
25+
26+
local manifestVersion = GetResourceMetadata(GetCurrentResourceName(), "version", 0)
27+
28+
print("Resource: " .. resourceName)
29+
print("Manifest Version: " .. manifestVersion)
30+
print("Remote Version: " .. remoteVersion)
31+
print("Description: " .. description)
32+
33+
if manifestVersion ~= remoteVersion then
34+
print("Status: Out of Date (New Version: " .. remoteVersion .. ")")
35+
print("Changelog:")
36+
for _, change in ipairs(changelog) do
37+
print("- " .. change)
38+
end
39+
print("Link to Updates: https://discord.gg/cfxdev")
40+
else
41+
print("Status: Up to Date")
42+
end
43+
else
44+
print("Resource name not found in the response.")
45+
end
46+
else
47+
print("HTTP request failed with status code: " .. statusCode)
48+
end
49+
end, "GET", nil, json.encode({}), {})
50+
end
51+
52+
53+
54+

0 commit comments

Comments
 (0)