View previous topic :: View next topic |
Author |
Message |
LastExceed Expert Cheater Reputation: 1
Joined: 05 Nov 2014 Posts: 130
|
Posted: Sun Nov 01, 2015 3:47 am Post subject: CE attaches to process at last instead of in the beginning |
|
|
I have a script that works fine when I first attach CE to the process manually. However if I put Code: | getAutoAttachList().add("cube.exe") |
into the very first line, it still somehow attaches AFTER executing the rest of the code (which of course leads to tons of errors), instead of first attaching and then proceeding to the rest of the code. I tried using , but that didn't help. I then created 2 buttons, one for attaching to the process and one for executing the script, and it works fine if I press them in the correct order Code: | function CEButtonAttachClick(sender)
getAutoAttachList().add("cube.exe")
end
function CEButtonExecuteClick(sender)
blabla
myscript
wont paste it in here because its too long
and it doesnt matter anyway
end |
But there must be a way to do it differently. What did I do wrong?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Sun Nov 01, 2015 4:07 am Post subject: |
|
|
This code will open the process
Code: |
processNameToOpen=string.lower("cube.exe")
sl=createStringlist()
getProcessList(sl)
for i=0,sl.Count-1 do
pid=tonumber('0x'..string.sub(sl[i],1,8))
name=string.lower(string.sub(sl[i],10,#sl[i]))
if name==processNameToOpen then
openProcess(pid)
reinitializeSymbolhandler()
break
end
end
sl.destroy()
|
_________________
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 |
|
|
LastExceed Expert Cheater Reputation: 1
Joined: 05 Nov 2014 Posts: 130
|
Posted: Sun Nov 01, 2015 4:11 am Post subject: |
|
|
Dark Byte wrote: | This code will open the process
Code: |
processNameToOpen=string.lower("cube.exe")
sl=createStringlist()
getProcessList(sl)
for i=0,sl.Count-1 do
pid=tonumber('0x'..string.sub(sl[i],1,8))
name=string.lower(string.sub(sl[i],10,#sl[i]))
if name==processNameToOpen then
openProcess(pid)
reinitializeSymbolhandler()
break
end
end
sl.destroy()
|
|
Thanks, works now
Can you explain what exactly this code does? I'd like to understand my code rather than copy-pasting stuff from the internet until it works :O
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Sun Nov 01, 2015 6:10 am Post subject: |
|
|
first it creates a stringlist
then getProcessList is called to fill it with the processlist
then the list is scanned through (for loop).
the strings (pid-name) are split up into two seperate strings and then the name is compared against what you're looking for. (lowercase)
if it matches, then open the process, reload the symbolhandler immediately (in case your script wants to use symbols right away) and then stop scanning through the list
and finally it frees the processlist
_________________
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 |
|
|
LastExceed Expert Cheater Reputation: 1
Joined: 05 Nov 2014 Posts: 130
|
Posted: Sun Nov 01, 2015 6:27 am Post subject: |
|
|
Dark Byte wrote: | first it creates a stringlist
then getProcessList is called to fill it with the processlist
then the list is scanned through (for loop).
the strings (pid-name) are split up into two seperate strings and then the name is compared against what you're looking for. (lowercase)
if it matches, then open the process, reload the symbolhandler immediately (in case your script wants to use symbols right away) and then stop scanning through the list
and finally it frees the processlist |
Thanks alot!
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Nov 01, 2015 7:23 am Post subject: |
|
|
Are you using onOpenProcess function? If not, try this:
Put all your code in one big function, INIT. And then use onOpenProcess function.
Code: | function INIT()
if alreadyinitiaized then return else alreadyinitiaized=true end
reinitializeSymbolhandler()
-- paste here all your code
--
end
getAutoAttachList().add("cube.exe")
function onOpenProcess()
INIT()
end |
(note: we can put function implementation inside other function, it is nothing weird for Lua coders)
_________________
|
|
Back to top |
|
|
|