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 


Help Lua Script Detector game process (Not auto attach)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
dario3star
Newbie cheater
Reputation: 0

Joined: 14 Dec 2020
Posts: 23

PostPosted: Tue Feb 23, 2021 8:35 pm    Post subject: Help Lua Script Detector game process (Not auto attach) Reply with quote

Hello, someone here gave me lua code for auto attach months ago thank u.
But today i don't know how to code Process Detector only. The plan is if my game detected, my main script will run itself. But if my game got crashed or closed and the process is not detected anymore, my "other" script will run.
Sorry bad english, i'm so bad in english that's why i'm confused how to explain it. I have the sample code but this is "Auto Attach". Please help me make it to just process detector and where to put my main script and "else" script. Thank you so much.
---------------------------------------------------------------

PROCESS_NAME = 'mygame.exe'
--------
--------
--------
local autoAttachTimer = nil ---- variable to hold timer object
local autoAttachTimerInterval = 1000 ---- Timer intervals are in milliseconds
local autoAttachTimerTicks = 0 ---- variable to count number of times the timer has run
local autoAttachTimerTickMax = 5000 ---- Set to zero to disable ticks max
local function autoAttachTimer_tick(timer) ---- Timer tick call back
---- Destroy timer if max ticks is reached
if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then
timer.destroy()
end
---- Check if process is running
if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then
timer.destroy() ---- Destroy timer
openProcess(PROCESS_NAME) ---- Open the process
end
autoAttachTimerTicks = autoAttachTimerTicks + 1 ---- Increase ticks
end
autoAttachTimer = createTimer(getMainForm()) ---- Create timer with the main form as it's parent
autoAttachTimer.Interval = autoAttachTimerInterval ---- Set timer interval
autoAttachTimer.OnTimer = autoAttachTimer_tick ---- Set timer tick call back
MainForm.hide()
Back to top
View user's profile Send private message AIM Address
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Tue Feb 23, 2021 9:18 pm    Post subject: This post has 1 review(s) Reply with quote

Example:

Code:
function checkAttachedProcessStatus(is_open)
    local m = enumModules();

    -- if process opened and everything just fine
    -- run 'the hack scipt'

    if (#m > 0) then
        is_open = m[1].Name
        print(is_open..' is running')
        return m[1].Name

    -- if opened process has closed or crash
    -- run 'other hack' script
    else
        print(is_open..' not found or crash')
        return nil
    end
end

checkAttachedProcessStatus('notepad.exe')

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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