View previous topic :: View next topic |
Author |
Message |
Mobie Cheater
Reputation: 0
Joined: 10 Feb 2011 Posts: 43
|
Posted: Sun Nov 25, 2018 12:56 pm Post subject: add value script press key |
|
|
hello i want a script to add a value when i press the key my script here
pushfd
pushad
push '96'
call GetAsyncKeyState
shr ax,#15
cmp ax,1
popad
add [eax+554],(int)1000
write constantly the 1000 value when i press Numpad 0 (keycode ), but i want only add
thanks |
|
Back to top |
|
 |
OldCheatEngineUser Whateven rank
Reputation: 20
Joined: 01 Feb 2016 Posts: 1586
|
Posted: Sun Nov 25, 2018 3:49 pm Post subject: |
|
|
you cant use the process thread, either create a new thread or find a pointer and set a hotkey. _________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote: | i am a sweetheart. |
|
|
Back to top |
|
 |
Csimbi I post too much
Reputation: 97
Joined: 14 Jul 2007 Posts: 3325
|
Posted: Mon Nov 26, 2018 1:14 am Post subject: Re: add value script press key |
|
|
Mobie wrote: | hello i want a script to add a value when i press the key my script here
pushfd
pushad
push '96'
call GetAsyncKeyState
shr ax,#15
cmp ax,1
popad
add [eax+554],(int)1000
write constantly the 1000 value when i press Numpad 0 (keycode ), but i want only add
thanks |
That will cause a crash, undoubtedly, because you never popped the flags.
But. Do you really need to push the flags?
You might, but often time it's not needed and you waste CPU cycles with that.
Either way, the 'add' instruction (like a few others) also updates the flags, so be sure to pop it afterwards.
Here's your code:
Code: | pushfd
pushad
push 60 // VK_NUMPAD0
call GetAsyncKeyState
shr ax,#15
cmp ax,1
jne short skip
add [eax+554],(int)1000
skip:
popad
popfd
|
If you chose to include it in the game code, you should pay attention to how often it's called.
If it's called a 1000 times a second, your tap on the NUMPAD0 for a sec will give you a million
For that reason, using a thread and a controlled timer is usually a better choice, |
|
Back to top |
|
 |
OldCheatEngineUser Whateven rank
Reputation: 20
Joined: 01 Feb 2016 Posts: 1586
|
Posted: Mon Nov 26, 2018 7:56 am Post subject: |
|
|
sorry i thought its getkeystate, and loops etc. _________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote: | i am a sweetheart. |
|
|
Back to top |
|
 |
Csimbi I post too much
Reputation: 97
Joined: 14 Jul 2007 Posts: 3325
|
Posted: Mon Nov 26, 2018 11:02 am Post subject: |
|
|
You should always prefer GetAsyncKeyState in CE because it pulls the current physical state rather than removing keys from the thread's message queue (which might be actually needed for the application itself). |
|
Back to top |
|
 |
|