Posted: Tue Feb 23, 2021 8:35 pm Post subject: Help Lua Script Detector game process (Not auto attach)
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()
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