Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[RESOLVED]Automatic .CETRAINER New Version Download!
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Thu Apr 12, 2018 1:09 pm    Post subject: Reply with quote

@Corroder Please .. Sad
the result is the same as the others.
It writes files on the table (.CT or .CETRAINER)
Files do not open, no changes are made.
Please check this code:
An onClick is querying the version.
The router is sending messages.
.CT downloading the file to the selected folder.
and replacing it with the old version which is open.

Code:
if syntaxcheck then return end
function CEButton1Click(sender)
local TABLE_VERSION = 1
local version_url = "https://docs.google.com/document/d/1h9fxfqztRnyamuXn75hElBEgf2OWJcogOPZBH3P9GN8/export?format=txt"
local table_url = "http://forum.cheatengine.org/download.php?id=119714"
local http = getInternet()
local result = http.getURL(version_url)
if result then
  local version = tonumber(result:match("%d+"))
  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("Be sure to save the new table!", mtInformation, mbOK)
      local latest = http.getURL(table_url)
      if latest ~= nil then
        local name = os.getenv("TEMP")
        name = name .. "\\Zanzer.CT"
        local file = io.open(name, "w")
        file:write(latest)
        file:close()
        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()
assert(true)
end


This code should be edited, I do not know, maybe. Idea
.CETRAINER file must be downloaded, Idea
must close the old version, you must delete and should open in a new version. Idea
An idea like that. Rolling Eyes Idea
Please check again.
My brain has stopped! Sad Sad Sad

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Apr 12, 2018 5:46 pm    Post subject: Reply with quote

@Aylin
Quote:
It writes files on the table (.CT or .CETRAINER)


May I ask you, when you upload your script to a web host (i.e dropbox, ggogle doc, etc), WHAT is you uploaded ?. A CT or CETRAINER FILE ?. or a TEXT SCRIPT ?.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Thu Apr 12, 2018 7:17 pm    Post subject: Reply with quote

Corroder wrote:
@Aylin
Quote:
It writes files on the table (.CT or .CETRAINER)


May I ask you, when you upload your script to a web host (i.e dropbox, ggogle doc, etc), WHAT is you uploaded ?. A CT or CETRAINER FILE ?. or a TEXT SCRIPT ?.


I tested it in many formats.
Download failed. But he writes it down.
The file that the code wrote does not open.

https://docs.google.com/document/d/1OVn7FvHXUBLmEwX6ujOUW10U4WqJdb6eXo9aXGO3ZGw/edit

https://docs.google.com/document/d/1pWAmekmtpcaI56fhW0bVVCshBp5d9MGFQPUr0gxdh6U/edit

https://www.dropbox.com/home?preview=specimen33-tra.CETRAINER

https://www.dropbox.com/home?preview=specimen1.lua

https://www.dropbox.com/home?preview=specimen1.CT

https://www.dropbox.com/home?preview=specimen2.CT

etc.. etc.. etc.. Rolling Eyes

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Apr 12, 2018 8:09 pm    Post subject: Reply with quote

It depending how you wrote your script and upload it to web host.

Try this code to run your script :

Code:
function getUpdate()
 local newVersion = "https://hastebin.com/raw/codumaveva"
 local http = getInternet()
 local newTable = http.getURL(newVersion)
 if newTable ~= nil then
 local table_path = TrainerOrigin or getMainForm()
 name = table_path..'\\game.CT'
 local file = io.open(name, "w")
 file:write(newTable)
 file:close()
 loadTable(name)
 opening_form.visible = false
 else
 showMessage("Unable to updating new table")
 http.destroy()
 end
end

function checkUpdate()
 if syntaxcheck then return end
 local current_version = 2
 local new_version_url = "https://docs.google.com/document/d/1h9fxfqztRnyamuXn75hElBEgf2OWJcogOPZBH3P9GN8/export?format=txt"
 local http = getInternet()
 local result = http.getURL(new_version_url)
 local version = tonumber(result:match("%d+"))
 if result ~= current_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
 getUpdate()
 showMessage("You currently have the latest version!")
 return
 else
 return
 end
 end
 http.destroy()
 assert(true)
end

opening_form = createForm()
opening_form.setSize(100,100)
opening_form.position = 'poScreenCenter'
opening_form.visible = true

b = createButton(opening_form)
b.setSize(80,40)
b.left = (opening_form.width - b.width) / 2
b.top = (opening_form.height - b.height) / 2
b.caption = 'Check Table'
b.onClick = checkUpdate

opening_form.show()


To see how I wrote your script on the web host, try open this URL :

https://hastebin.com/raw/codumaveva

EDIT :
since pastebin has blocked on your country, then try other sites like pastebin i,e :
Tinypaste, Chop, hastebin, Snipt, etc instead using google docs. Because when you post your script onto google docs, usually it's change your script format.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Thu Apr 12, 2018 9:34 pm    Post subject: Reply with quote

Aylin wrote:
Corroder wrote:
@Aylin
Quote:
It writes files on the table (.CT or .CETRAINER)


May I ask you, when you upload your script to a web host (i.e dropbox, ggogle doc, etc), WHAT is you uploaded ?. A CT or CETRAINER FILE ?. or a TEXT SCRIPT ?.


I tested it in many formats.
Download failed. But he writes it down.
The file that the code wrote does not open.

https://docs.google.com/document/d/1OVn7FvHXUBLmEwX6ujOUW10U4WqJdb6eXo9aXGO3ZGw/edit

https://docs.google.com/document/d/1pWAmekmtpcaI56fhW0bVVCshBp5d9MGFQPUr0gxdh6U/edit

https://www.dropbox.com/home?preview=specimen33-tra.CETRAINER

https://www.dropbox.com/home?preview=specimen1.lua

https://www.dropbox.com/home?preview=specimen1.CT

https://www.dropbox.com/home?preview=specimen2.CT

etc.. etc.. etc.. Rolling Eyes



Every on of these just give an error, "Data Error".
Lets start with a working file by it self and go from there.
And Dropbox requires an ID cookie this won't work.

_________________
Back to top
View user's profile Send private message Visit poster's website
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Fri Apr 13, 2018 7:09 am    Post subject: Reply with quote

TheyCallMeTim13 wrote:

Every on of these just give an error, "Data Error".
Lets start with a working file by it self and go from there.
And Dropbox requires an ID cookie this won't work.


In fact, for all users,
  As a joint and unprotected download platform,
  I chose DropBox.
I will look for an alternative Download site.
Thanks I'll try again today.

@Corroder;
I will absolutely try.
thanks for the solutions.

----------------------------------------------

I also thank you guys. Smile
You are helping with your knowledge and patience.
-- (Strange: People are following the forum,
-- I think there are users waiting for results.
-- Instead of participating, only as audience!)
I hope everyone is satisfied with the end result. Rolling Eyes

EDIT:

TheyCallMeTim13 wrote:

Every on of these just give an error, "Data Error".
Lets start with a working file by it self and go from there.
And Dropbox requires an ID cookie this won't work.



The link below gives a sample CT file.
Please download and Test Version. (It works with a minor error Wink )

DropBox normal connection:

https:// "www.dropbox.com" /s/ex7assm6v4awv7j/GameV32.CT?dl= "0"

DropBox Direct download link:

https://dl.dropboxusercontent.com/s/ex7assm6v4awv7j/GameV32.CT?dl=1
or
https://www.dropbox.com/s/ex7assm6v4awv7j/GameV32.CT?dl=1
Please download and Version Test it.

DropBox is working, responding to remote download command.
I sent this only to test DropBox.
Now I try @Corrod code.
I will write the result.



Entertainment must continue.png
 Description:
 Filesize:  98.02 KB
 Viewed:  9057 Time(s)

Entertainment must continue.png



_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Fri Apr 13, 2018 6:05 pm    Post subject: Reply with quote

TheyCallMeTim13 wrote:
Why not download the new .CETRAINER to the current working folder, so if the user is at "...\Trainers\game name" you download here and just add the version number to the name so like "game.v1-0-1.CETRAINER" then just use "os.execute" to launch the new trainer then close the old one when you detect the new one running.


Thanks and FINAL!!! Smile

"os.execute" It was a life-saving details.

and example Trainer:
https://dl.dropboxusercontent.com/s/6ro1jgyzqkuchhs/GameV32.CETRAINER?dl=1

and Code:

Code:
if syntaxcheck then return end

function CEButton5Click(sender)
local TABLE_VERSION = 32
local version_url = "https://docs.google.com/document/d/14OcroOlC5xX6igGg42_OpiHXCDWs-vUxTvVZBEynMnI/export?format=txt"
local table_url = "https://dl.dropboxusercontent.com/s/x7bdrwdv9aj9zel/GameV33.CETRAINER?dl=1"
local http = getInternet()
local result = http.getURL(version_url)
if result then
  local version = tonumber(result:match("%d+"))
  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("Be sure to save the new table!", mtInformation, mbOK)
      local latest = http.getURL(table_url)
      if latest ~= nil then
      path = TrainerOrigin or getMainForm()
local name = path .. "\\GameV33.CETRAINER"
        local file = io.open(name, "wb")
        file:write(latest)
        file:close()
       local name = os.execute(name, "\\GameV33.CETRAINER")
--       os.remove(file)
        closeCE()
--        if useExist(file) then os.remove(file) end
        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()
assert(true)
end


there is only one missing.
please complete.
After the new version is installed,
A coding needed to clear off the old version.
like os.remove (file)

Thank you for all your efforts.
old version, still need the delete code. Rolling Eyes

and Thanks @Zanzer Smile

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Fri Apr 13, 2018 8:53 pm    Post subject: Reply with quote

Aylin wrote:
...


Code:
os.execute(name, "\\GameV33.CETRAINER")

Ok, so a CETRAINER still needs to be reexecuted like an EXE. So I'm thinking have an option for trainers, if true; install new one, write old ones name to file, start new one, close old one, then new one detects file and removes old one (say with an "isFirstLaunch()" function or an "onFirstLaunch()" event).

_________________
Back to top
View user's profile Send private message Visit poster's website
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Sat Apr 14, 2018 5:45 am    Post subject: Reply with quote

TheyCallMeTim13 wrote:
close old one, then new one detects file and removes old one (say with an "isFirstLaunch()" function or an "onFirstLaunch()" event).





Code:
local file = os.remove(path .. "\\GameV32.CETRAINER");


and Message:

Code:
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)


but there is a risk:
If the user tamper with the name of the old version,
it may not match the name in the delete code,
and can give this error.
This code, in conjunction with "closeCE ()", anonymous,
Can we connect with "path" or "TrainerOrigin"?
or it may be about as anonymous code.

FirstLaunch() Can he provide this?
Could you give the built-in use of the code?

or we hope that the user does not spoil the Names. Smile

NOTE:
I noticed that; People take it and get it.
And appreciated; only with thanks or nothing!
But they are even too lazy to give a RAP Score!
This is great carelessness.
@TheyCallMeTim13 - @Corroder - @Zanzer ; I owe you a RAP score of the.
I will return them when the timeout is over.
Thanks again.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Sat Apr 14, 2018 6:00 am    Post subject: Reply with quote

So I'll be adding a "FirstLaunch" function/event. And the user can mess with a lot, so it's best just to prepare for the user to tamper with the name, then just prompt the user and say old file not found. The other option will be to use the "${Temp}" key the is provided (in my modules File path setting), I'll give an example on the nest version.

I really don't care about REP, more interested in knowing YOU learned a new skill.

_________________
Back to top
View user's profile Send private message Visit poster's website
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Sat Apr 14, 2018 6:24 am    Post subject: This post has 1 review(s) Reply with quote

TheyCallMeTim13 wrote:

I really don't care about REP, more interested in knowing YOU learned a new skill.


I'm still trying to find out.
I've had a lot of changes in the last eight months.
Now they're talking about trailers I do. This is a nice feeling.
For me; It is a virtue to consult the master and appreciate the masters.
Your sincerity, for your patience and wisdom: thank you all.


NOTE: I use the code as it is now.
As I learn, maybe I make a change.

Including old version deletion, final state:

https://www.dropbox.com/s/6ro1jgyzqkuchhs/GameV32.CETRAINER?dl=1

Thanks Masters ..

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites