Skip to content

Commit

Permalink
New updater
Browse files Browse the repository at this point in the history
  • Loading branch information
actuallykane committed Jan 7, 2019
1 parent fd61518 commit 1681328
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uuid
21 changes: 17 additions & 4 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1681328

Please sign in to comment.