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 


Close CE when quitting from game?

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

Joined: 06 Mar 2022
Posts: 2

PostPosted: Sun Mar 06, 2022 9:25 pm    Post subject: Close CE when quitting from game? Reply with quote

I was looking for a way to auto-close CE when I quit from the targeted game, or alternatively after a certain amount of time.

I tried creating a second timer so after some time it auto-closes, but whenever I try it it auto-closes instantly, without even the time for the game to read it. Can someone help me on this please?

Code:
getAutoAttachList().add('bblit2.exe')  --ce will now watch the process

function onOpenProcess(pid)
  local t=createTimer()
  t.OnInterval=30000 --wait 10 seconds to let the game load (change this accordingly. If it's a cheat that needs to be activated after loading a game, set it to a minute or two)

  t.OnTimer=function(x)
    local al=getAddressList()
    al.getMemoryRecordByDescription('Horizontal').Active=true
    al.getMemoryRecordByDescription('Horizontal').Value=38
    al.getMemoryRecordByDescription('Vertical').Active=true
    al.getMemoryRecordByDescription('Vertical').Value=38
    x.destroy() --the timer is not needed anymore
  end
end
function closing()
  local t2=createTimer()
  t2.OnInterval=80000

  t2.OnTimer=function(x)
    x.destroy()
    closeCE()
  end
end
destroy1=closing()
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1530

PostPosted: Sun Mar 06, 2022 10:46 pm    Post subject: Reply with quote

With a single timer and if the game is open, the code will be activated. Trainer will be closed in 10-12 seconds if the game is not open.


Code:
if clsTimer then clsTimer.Destroy() clsTimer=nil end
clsTimer=createTimer() clsTimer.Interval=1000 --1 sec

function activeCodeAndCloseTrainer()
clsTimer.Enabled=false
    local al=getAddressList()
    al.getMemoryRecordByDescription('Horizontal').Active=true
    al.getMemoryRecordByDescription('Horizontal').Value=38
    al.getMemoryRecordByDescription('Vertical').Active=true
    al.getMemoryRecordByDescription('Vertical').Value=38
end

local checkIndex=0

function Start()
checkIndex=tonumber(checkIndex) + 1
local procesID = getProcessIDFromProcessName('game.exe') --your game process name?
  if (procesID==nil) then
   showMessage("Opss! I guess the game is not open!\nIt will turn off in 10 seconds!\nPlease make sure the game is open!")
    if checkIndex==12 then closeCE() return caFree() end
   else
   openProcess(procesID)
   activeCodeAndCloseTrainer()
  end
end

clsTimer.Enabled=true -- The timer is active at startup.
clsTimer.OnTimer=Start

_________________
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
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Mon Mar 07, 2022 5:54 am    Post subject: Reply with quote

Code:

local t=createTimer(MainForm)
t.Interval=1000
t.OnTimer=function()
  if getOpenedProcessID()~=0 and readInteger(process)==nil then
    t.destroy()
    closeCE()
  end
end

_________________
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
manuelx98
How do I cheat?
Reputation: 0

Joined: 06 Mar 2022
Posts: 2

PostPosted: Mon Mar 07, 2022 10:30 am    Post subject: Reply with quote

Dark Byte wrote:
Code:

local t=createTimer(MainForm)
t.Interval=1000
t.OnTimer=function()
  if getOpenedProcessID()~=0 and readInteger(process)==nil then
    t.destroy()
    closeCE()
  end
end


It works! Thanks!! So what it does is check every second if the game is running and if not it closes CE, right?
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Mon Mar 07, 2022 11:02 am    Post subject: Reply with quote

Dark Byte wrote:
Code:

local t=createTimer(MainForm)
t.Interval=1000
t.OnTimer=function()
  if getOpenedProcessID()~=0 and readInteger(process)==nil then
    t.destroy()
    closeCE()
  end
end


If CE is closing why t.destroy?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Mon Mar 07, 2022 11:52 am    Post subject: Reply with quote

Imagine someone overriding closeCE with a version that asks if you're sure?
It would then start spamming the question and unable to stop it until the user closes CE.

This way it only tries to close CE once, and that's it

_________________
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
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Mon Mar 07, 2022 1:27 pm    Post subject: Reply with quote

In that case I understand, but in my case stand alone, no internet gaming on my end.
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Tue Mar 08, 2022 1:54 am    Post subject: Reply with quote

one more solution:
Code:
function IsAttached()
return getOpenedProcessID() == getProcessIDFromProcessName("gta_sa.exe")
end

local t = createTimer(nil)
t.Enabled = true
t.Interval = 1000
t.OnTimer = function()
if not IsAttached() and process  ~= nil then
t.destroy()
t = nil
closeCE()
end
end
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Tue Mar 08, 2022 9:36 am    Post subject: Reply with quote

Code:

   tstop = createTimer(nil)
   timer_setInterval(t, 1000)
   timer_setEnabled(tstop, true)--tstop.Enabled = true
   timer_onTimer = function(tstop)
                      if(getOpenedProcessID() ~= 0) and (readInteger("kernel32.dll") == nil) then
                         tstop.destroy();
                         closeCE();
                      end
                   end


Well I had to comment out tsop to allow the table to load.
Back to top
View user's profile Send private message Yahoo 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
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