From d8e8f4e239f8f38704fe043d9a34de9db1ab2446 Mon Sep 17 00:00:00 2001 From: Arcidayne <9382522b@opayq.com> Date: Mon, 21 Dec 2015 12:02:21 -0800 Subject: [PATCH] Added auto-updating --- .../Epic_Not_Here_Counter.xml | 43 ++++++++----------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/Epic_Not_Here_Counter/Epic_Not_Here_Counter.xml b/Epic_Not_Here_Counter/Epic_Not_Here_Counter.xml index 9157779..dfc1b80 100644 --- a/Epic_Not_Here_Counter/Epic_Not_Here_Counter.xml +++ b/Epic_Not_Here_Counter/Epic_Not_Here_Counter.xml @@ -15,7 +15,7 @@ save_state="y" date_written="2015-10-25 12:00:38" requires="4.00" - version="2" + version="1" > send_to="12" sequence="100" > - local pid = GetPluginID() - local pfile, pversion = GetPluginInfo(pid, 6), GetPluginInfo(pid, 19) - local raw = "https://raw.githubusercontent.com/Arcidayne/Aardwolf-Scripts/master/Epic_Not_Here_Counter/Epic_Not_Here_Counter.xml" - get_update(pid, pfile, pversion, raw) + if not IsPluginInstalled("dff6da0f0c8bd7605fe6a5f4") then + get_update() + else + local pid = GetPluginID() + local pfile = GetPluginInfo(pid, 6) + local pversion = GetPluginInfo(pid, 19) + CallPlugin("dff6da0f0c8bd7605fe6a5f4", "updateplugin", pid, pfile, pversion, "https://raw.githubusercontent.com/Arcidayne/Aardwolf-Scripts/master/Epic_Not_Here_Counter/Epic_Not_Here_Counter.xml") + end end - - DoAfterSpecial(2, 'ReloadPlugin("e6cd5104e883a1dd9c4362e2")', 12) - @@ -236,26 +230,23 @@ function OnPluginInstall() SetCounterDebug = 0 end -function get_update(pid, pfile, pversion, raw) +function get_updater() async_ok, async = pcall (require, "async") + local fname = GetPluginInfo(GetPluginID(), 20) .. "Updater.xml" if async_ok then updater_page = async.request("https://raw.githubusercontent.com/Arcidayne/Aardwolf-Scripts/master/Updater/Updater.xml", "HTTPS") end - retval, page, status, headers, full_status = updater_page:join() updater_page = nil - if status == 200 and not IsPluginInstalled("dff6da0f0c8bd7605fe6a5f4") then - local file = io.open(GetPluginInfo(pid, 20) .. "Updater.xml", "w") - file:write(page) - file:close() - LoadPlugin(GetPluginInfo(pid, 20) .. "Updater.xml") - end - - CallPlugin('dff6da0f0c8bd7605fe6a5f4', "UpdatePlugin", pid, pfile, pversion, raw) + if status == 200 then + file = io.open(fname, "w") + file:write(page) + file:close() + LoadPlugin(fname) + end end - ]]>