Display current and latest version in terminal #18

This commit is contained in:
okvdai
2023-05-03 17:39:59 +02:00
parent 53fb421662
commit 54d26f568b
3 changed files with 37 additions and 5 deletions
+16
View File
@@ -7,6 +7,22 @@
{
"Name": "ToneURL",
"DefaultValue": "https://tone.sleepycat.date/v2/client"
},
{
"Name": "VersionURL",
"DefaultValue": "https://raw.githubusercontent.com/ToneAPI/pulse/main/version.json"
},
{
"Name": "MajorVersion",
"DefaultValue": "1"
},
{
"Name": "MinorVersion",
"DefaultValue": "2"
},
{
"Name": "PatchVersion",
"DefaultValue": "1"
}
],
"Scripts": [
+18 -2
View File
@@ -33,9 +33,25 @@ int mapGamemodeEntries = 0
void function pulseInit()
{
HTTPrequestURL = GetConVarString("ToneURL")
prefix = "\x1b[38;2;255;178;102m[PULSE]\x1b[0m "
print(prefix + "v1.2.0 has been loaded.")
HTTPrequestURL = GetConVarString("ToneURL")
HttpRequest getVersion
getVersion.method = HttpRequestMethod.GET
getVersion.url = GetConVarString("VersionURL")
void functionref(HttpRequestResponse) onSuccess = void function(HttpRequestResponse response)
{
table JSONDecoded = DecodeJSON(response.body)
if ((JSONDecoded["Major"] == GetConVarString("MajorVersion")) && (JSONDecoded["Minor"] == GetConVarString("MinorVersion")) && (JSONDecoded["Patch"] == GetConVarString("PatchVersion"))) {
print(prefix + "v1.2.1 has been loaded and is up to date.")
} else {
print(prefix + "v1.2.1 has been loaded. Recommend updating to latest version: v" + JSONDecoded["Major"] + "." + JSONDecoded["Minor"] + "." + JSONDecoded["Patch"] + ".")
}
}
void functionref(HttpRequestFailure) onFailure = void function(HttpRequestFailure failure)
{
print(prefix + "v1.2.1 has been loaded and has encountered an error getting latest version data.")
}
NSHttpRequest(getVersion, onSuccess, onFailure)
}
void function GetWeaponStatsFromToneAPI()
+3 -3
View File
@@ -1,5 +1,5 @@
{
"Major": 1,
"Minor": 2,
"Patch": 1
"Major": "1",
"Minor": "2",
"Patch": "1"
}