-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.lua
More file actions
68 lines (55 loc) · 2.33 KB
/
version.lua
File metadata and controls
68 lines (55 loc) · 2.33 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
60
61
62
63
64
65
66
67
68
local version = "1.0.0"
local prefix = "^5[stgscripts.com]"
local script_name = "STG Basic Radio"
local VERSION_URL = "https://raw.githubusercontent.com/kyabaran/stg/main/basicradio.txt"
local CHECK_INTERVAL = 600000
local BOX_WIDTH = 46
local function stripColors(text)
return text:gsub("%^%d", "")
end
local function pad(text)
local len = #stripColors(text)
local space = BOX_WIDTH - len
if space < 0 then space = 0 end
return text .. string.rep(" ", space)
end
local function printBox(script_version, features)
print("^7┌" .. string.rep("─", BOX_WIDTH + 2) .. "┐^7")
print("^7│ " .. pad("^3" .. script_name .. " ^7– ^1OUTDATED VERSION DETECTED") .. " ^7 │^7")
print("^7├" .. string.rep("─", BOX_WIDTH + 2) .. "┤^7")
print("^7│ " .. pad("^7Current Version : ^1" .. version) .. " ^7│^7")
print("^7│ " .. pad("^7Latest Version : ^2" .. script_version) .. " ^7│^7")
print("^7├" .. string.rep("─", BOX_WIDTH + 2) .. "┤^7")
print("^7│ " .. pad("^5Update URL:^7 https://portal.cfx.re/") .. " ^7│^7")
print("^7├" .. string.rep("─", BOX_WIDTH + 2) .. "┤^7")
print("^7│ " .. pad("^5New Features:^7") .. " ^7│^7")
for _, feature in ipairs(features) do
print("^7│ " .. pad("^7• " .. feature) .. " ^7│^7")
end
print("^7└" .. string.rep("─", BOX_WIDTH + 2) .. "┘^7")
end
local function CheckScriptVersion()
print(prefix.." ^3[" .. script_name .. "]^7 Checking script version...")
PerformHttpRequest(VERSION_URL, function(err, text)
if err ~= 200 or not text or text == "" then
print(prefix.." ^1[" .. script_name .. "]^7 Version check failed.")
return
end
local data = json.decode(text)
if not data or not data.version then
print(prefix.." ^1[" .. script_name .. "]^7 Invalid version data.")
return
end
local latest_version = data.version
local features = data.new_features or {}
if latest_version == version then
print(prefix.." ^2[" .. script_name .. "]^7 Script is up to date! (v" .. version .. ")")
return
end
while true do
printBox(latest_version, features)
Citizen.Wait(CHECK_INTERVAL)
end
end, "GET")
end
Citizen.CreateThread(CheckScriptVersion)