-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsv_versionCheck.lua
64 lines (60 loc) · 3.16 KB
/
sv_versionCheck.lua
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
60
61
62
63
64
--[[ Version Checker ]] --
local version = "100"
local DISCORD_WEBHOOK = ""
local DISCORD_NAME = "AN - ENGINES"
local DISCORD_IMAGE = "https://cdn.discordapp.com/attachments/1026175982509506650/1026176123928842270/Lanzaned.png"
AddEventHandler("onResourceStart", function(resource)
if resource == GetCurrentResourceName() then
checkResourceVersion()
end
end)
function checkUpdateEmbed(color, name, message, footer)
local content = {
{
["color"] = color,
["title"] = " " .. name .. " ",
["description"] = message,
["footer"] = {
["text"] = " " .. footer .. " ",
},
}
}
PerformHttpRequest(DISCORD_WEBHOOK, function(err, text, headers) end,
'POST', json.encode({
username = DISCORD_NAME,
embeds = content,
avatar_url = DISCORD_IMAGE
}), { ['Content-Type'] = 'application/json '})
end
function checkResourceVersion()
PerformHttpRequest("https://raw.githubusercontent.com/Annalouu/an-engines/main/version.txt", function(err, text, headers)
if (version > text) then -- Using Dev Branch
print(" ")
print("---------- ANNALOU | ENGINES ----------")
print("Engines is using a development branch! Please update to stable ASAP!")
print("Your Version: " .. version .. " Current Stable Version: " .. text)
print("https://github.com/Annalouu/an-engines")
print("-----------------------------------------------")
print(" ")
checkUpdateEmbed(5242880, "an-engines Update Checker", "an-engines is using a development branch! Please update to stable ASAP!\nYour Version: " .. version .. " Current Stable Version: " .. text .. "\nhttps://github.com/Annalouu/an-engines", "Script created by: https://discord.gg/94fqva84vb")
elseif (text < version) then -- Not updated
print(" ")
print("---------- ANNALOU | ENGINES ----------")
print("Engines is not up to date! Please update!")
print("Curent Version: " .. version .. " Latest Version: " .. text)
print("https://github.com/Annalouu/an-engines")
print("-----------------------------------------------")
print(" ")
checkUpdateEmbed(5242880, "an-engines Update Checker", "an-engines is not up to date! Please update!\nCurent Version: " .. version .. " Latest Version: " .. text .. "\nhttps://github.com/Annalouu/an-engines", "Script created by: https://discord.gg/94fqva84vb")
else -- resource is fine
print(" ")
print("---------- ANNALOU | ENGINES ----------")
print("Engines is up to date and ready to go!")
print("Running on Version: " .. version)
print("https://github.com/Annalouu/an-engines")
print("-----------------------------------------------")
print(" ")
checkUpdateEmbed(20480, "an-engines Update Checker", "an-engines is up to date and ready to go!\nRunning on Version: " .. version .. "\nhttps://github.com/Annalouu/an-engines", "Script created by: https://discord.gg/94fqva84vb")
end
end, "GET", "", {})
end