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 


auto terminate trainer if game exe is not found

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Mon Oct 05, 2020 7:48 am    Post subject: Reply with quote

Code:

if not OpenProcess('GenshinImpact.exe') then closeCE() end


and also saves you from having to use the autoattach routine

_________________
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
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Mon Oct 05, 2020 8:03 am    Post subject: Reply with quote

if 'Genshin Impact'=='Online multiplayer game' then
showMessage('Cheat Engine; It does not support online multiplayer game hacking. Please conclude the topic.')
else


--Here is the code you need; You can attribute this to a timer.

Code:
function ProcessCheck()
local pdn=('GenshinImpact.exe')
op=openProcess(pdn)
if (op==nil) then
showMessage("GenshinImpact not found!");
closeCE()
return caFree
else
openProcess(pdn)
local pd=getOpenedProcessID()
showMessage("Game: "..pdn.." - PID: "..tonumber(pd))
end
end

ProcessCheck()
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Mon Oct 05, 2020 8:18 am    Post subject: Reply with quote

after the OpenProcess check add
Code:

t=createTimer(nil)
t.Interval=100
t.OnTimer=function()
  if readInteger(process)==nil then
    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
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Mon Oct 05, 2020 8:22 am    Post subject: Reply with quote

Code:
if tCheck then tCheck.destroy() end
tCheck=createTimer()
tCheck.Interval=5000 --5 sec
tCheck.Enabled=true

tCheck.OnTimer=function()
--DB code
if not OpenProcess('GenshinImpact.exe') then
showMessage("The game is not open. Trainer shuts down.")
sleep(300)
closeCE() end
--or ProcessCheck code
--ProcessCheck()
end


--
Back to top
View user's profile Send private message
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