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 


Process Exit detection.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
EntityReborn
How do I cheat?
Reputation: 0

Joined: 15 Aug 2010
Posts: 9

PostPosted: Wed Oct 16, 2013 2:19 pm    Post subject: Process Exit detection. Reply with quote

Is there currently a way to tell when a process you are attached to exits? I'd like to make my trainer re-attach if the target dies and is restarted.
Back to top
View user's profile Send private message
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Wed Oct 16, 2013 3:59 pm    Post subject: Reply with quote

just create a timer that opens the process every second.
_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
EntityReborn
How do I cheat?
Reputation: 0

Joined: 15 Aug 2010
Posts: 9

PostPosted: Wed Oct 16, 2013 4:21 pm    Post subject: Reply with quote

Code:
t = createTimer(nil)
timer_onTimer(t, checkAttached)
timer_setInterval(t, 1000)
timer_setEnabled(t, true)
pid = 0

function onOpenProcess(id)
  if (id ~= pid) then
    pid = id
    print("Connected")
  end
end

function checkAttached()
  print("Checking...")

  openProcess( "JustCause2.exe" )

  local newpid = getOpenedProcessID()
  print("oldpid:"..pid)
  print("newpid:"..newpid)
end


With this above code, even after I close the target, newpid remains set as the old id. IOW, newpid == pid.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25796
Location: The netherlands

PostPosted: Wed Oct 16, 2013 5:18 pm    Post subject: Reply with quote

checkAttached never gets called because it‘s not yet declared when you assign it to the timer
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
EntityReborn
How do I cheat?
Reputation: 0

Joined: 15 Aug 2010
Posts: 9

PostPosted: Wed Oct 16, 2013 5:19 pm    Post subject: Reply with quote

This is just a small piece of code, from a larger chunk. I do indeed get the print statements in the Lua console.

EDIT:

Also, could you somehow include an environment reset for testing scripts? One example of this is, hitting Execute script in the script editor causes previous timers to keep ticking, etc. If possible, a full environment reload such as when loading a script from file would be excellent, with a seperate button.
Back to top
View user's profile Send private message
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Thu Oct 17, 2013 11:13 am    Post subject: Reply with quote

you can destroy timers.
and resetLuaState can also help.

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
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