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 


add value script press key

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Mobie
Cheater
Reputation: 0

Joined: 10 Feb 2011
Posts: 43

PostPosted: Sun Nov 25, 2018 12:56 pm    Post subject: add value script press key Reply with quote

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
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Sun Nov 25, 2018 3:49 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3325

PostPosted: Mon Nov 26, 2018 1:14 am    Post subject: Re: add value script press key Reply with quote

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 Wink

For that reason, using a thread and a controlled timer is usually a better choice,
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Mon Nov 26, 2018 7:56 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3325

PostPosted: Mon Nov 26, 2018 11:02 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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