From 16813286a7eb6d5af511d85800a75eacc1fcef8e Mon Sep 17 00:00:00 2001 From: Kanersps Date: Mon, 7 Jan 2019 10:13:40 +0100 Subject: [PATCH] New updater --- .gitignore | 1 + server/main.lua | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bcc6f36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +uuid \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index b5f26a4..e7d29bb 100644 --- a/server/main.lua +++ b/server/main.lua @@ -8,15 +8,28 @@ _VERSION = '5.2.0' -- Server -- Version check -PerformHttpRequest("https://kanersps.pw/fivem/version.txt", function(err, rText, headers) +local VersionAPIRequest = "https://api.kanersps.pw/em/version?version=" .. _VERSION .. "&uuid=" .. (LoadResourceFile(GetCurrentResourceName(), "uuid") or "unknown") +print("Performing version check against: " .. VersionAPIRequest) +PerformHttpRequest(VersionAPIRequest, function(err, rText, headers) print("\nCurrent version: " .. _VERSION) + local decoded = json.decode(rText) + if err == 200 then - print("Updater version: " .. rText .. "\n") + print("Updater version: " .. decoded.newVersion .. "\n") - if rText ~= _VERSION then - print("\nVersion mismatch, you are currently not using the newest stable version of essentialmode. Please update\n") + if(decoded.uuid)then + SaveResourceFile(GetCurrentResourceName(), "uuid", decoded.uuid, -1) + end + + if not decoded.updated then + print("Changelog: \n" .. decoded.changes .. "\n") + print("You're not running the newest stable version of EssentialMode please update:\n" .. decoded.updateLocation) log('Version mismatch was detected, updater version: ' .. rText .. '(' .. _VERSION .. ')') + + if decoded.extra then + print(decoded.extra) + end else print("Everything is fine!\n") end