ByTransient Expert Cheater
Reputation: 5 Joined: 05 Sep 2020 Posts: 240
|
Posted: Thu Oct 07, 2021 8:15 pm Post subject: |
|
|
If you're still in this code, let me expand on the topic with some explanations.
-----------------------------------------------
The main code is here:
@Zanzer: https://forum.cheatengine.org/viewtopic.php?t=597759
-----------------------------------------------
1) Make sure the URL will download the current trainer.
2) Upload your updates to a site that will always use the same URL.
3) Define a path for the current Trainer.
Code: | local path = TrainerOrigin or getMainForm() |
4) If you are going to download the new version to a different location, identify it as well.
Code: | local path1=[[D:\downloader]]
local name = path1 .. "\\" .. newName |
5) Create another url for version test and Trainer name.
Code: | local versionNum = 0
local ExVersion = 01
local newName=""
UDF1.CEButton1.Caption="Download"
local path = TrainerOrigin or getMainForm() --Ex Trainer path..
local path1=[[D:\downloader]] --New Trainer path..
function loadUrl(link33)
local int=getInternet()
s=int.getURL(link33)
int.destroy()
return s
end
function VersionCheck()
local result = loadUrl("https://docs.google.com/document/d/1_Px-WKrnyw8MsqmwJnz2__eufO6cey653n77VZTDEok/export?format=txt")
local SL1 = createStringlist()
SL1.Text=result
for i=0, strings_getCount(SL1)-1 do
versionNum=SL1[1]--:sub(1,9)
newName=SL1[2]
versionNum=tonumber(versionNum)
ExVersion=tonumber(ExVersion)
end
SL1.destroy()
if versionNum==ExVersion then
UDF1.CEButton1.Enabled=false
else
showMessage("There is a new version.\nClick the 'Download' button to download!")
UDF1.CEButton1.Enabled=true
end
end
VersionCheck() --Open Trainer.. Execute func..
local name = path1 .. "\\" .. newName
function TrainerUpload()
if syntaxcheck then return end
local TABLE_VERSION = tonumber(ExVersion)
local table_url = "https://docs.google.com/uc?export=download&id=1d-lCWA1fAEpkPDTxvjGu4dxgNSRCj1E0"
local http = getInternet()
local version = tonumber(versionNum)
if version > TABLE_VERSION then
local answer = messageDialog("There is a newer version of this table.\nWould you like to download it now?", mtWarning, mbYes, mbNo)
if answer == mrYes then
messageDialog("Caution:\nThis update will permanently delete the old version.\nIf you do not want to delete the old version,\nget a copy before you approve!", mtInformation, mbOK)
local latest = http.getURL(table_url)
if latest ~= nil then
local file = io.open(name, "wb")
file:write(latest)
file:close()
local name = os.execute(name, "\\"..newName);
--local file = os.remove(ExName)
--closeCE()
loadTable(name)
else
messageDialog("Failed to load the new table!", mtError, mbOK)
end
end
else
messageDialog("You currently have the latest version!", mtInformation, mbOK)
end
--else
-- messageDialog("Failed to find latest version!", mtError, mbOK)
--end
http.destroy()
-- int.destroy()
assert(true)
end
UDF1.CEButton1.OnClick function()
TrainerUpload()
end |
Note: For ".exe" files, remote invocation may fail due to possible security errors in the installation and run procedures. My recommendation; Use the above code with ".CT" or ".Cetrainer".
|
|