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 


Script triggered by button press

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

Joined: 23 Dec 2009
Posts: 22

PostPosted: Wed Feb 15, 2012 10:59 am    Post subject: Script triggered by button press Reply with quote

I have been searching the forums for this but somehow I have missed it. I'm sure it is mentioned somewhere but I can't find it.

So far in my scripts I have just been modifying what happens on an event in game (for example: player gains money -> player gains much more money). What I want to know is, how do I make it so that the player presses a button and a script is executed once (not toggled on but rather just executed).

To be clear:


    Player wants to add experience.
    Player presses hotkey.
    Script is executed that adds 1000 XP to player character (0x3E8).
    Player is free to trigger script again whenever they wish.


I'm sorry for asking as I really expect it has already been answered, but thank you for your help Smile

_________________
---

Too bad my life doesn't have a hex address for suck...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 474

Joined: 09 May 2003
Posts: 25928
Location: The netherlands

PostPosted: Wed Feb 15, 2012 11:08 am    Post subject: Reply with quote

easiest is just a cheat entry with an assigned hotkey that does that instead of an script
Rightclick the entry, assign a hotkey, and choose the option to increase value by, and fill in 1000

You just have to make sure that the address is valid (e.g. a aa script that gets the latest correct address and writes it somewher, and the cheat entry being a pointer type)

Alternatively, if you do code injection in an often executed part of code, look up the getasynckeystate method and execute an increase only when the key is down

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Nakor
Newbie cheater
Reputation: 0

Joined: 23 Dec 2009
Posts: 22

PostPosted: Wed Feb 15, 2012 11:10 am    Post subject: Reply with quote

Ok thank you. I don't know how to do those things yet but I will look into them.

--

Ok one more question here:

The code that executes when a player gains experience also does a compare (JAE) to see if the character should level up or not. I am now attempting to add 1000 XP when a button is pressed as you said but the check to see if a level up should happen is not being executed (the 1000 XP is added but the level up check does not happen). I handled this in my script to increase the amount of XP the char gains each time, but since this is a hotkey and not a script I don't see how to handle it.

_________________
---

Too bad my life doesn't have a hex address for suck...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 474

Joined: 09 May 2003
Posts: 25928
Location: The netherlands

PostPosted: Wed Feb 15, 2012 12:24 pm    Post subject: Reply with quote

What happens after you gain 1 point of experience in the game?
do you level up then ?

There isn't really an easy method to automatically level up on keypress, the code that checks if you should level up needs to be called at least once

The complex method is find code that is related to the increase experience code and executed every frame, and there call the function that increases experience if the hotkey is pressed, giving it the correct cpu/stack state before calling and restoring the state as well.
Not recommended and I don't think it's worth the time if you gain the level as soon as you gain some experience the normal way

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Nakor
Newbie cheater
Reputation: 0

Joined: 23 Dec 2009
Posts: 22

PostPosted: Wed Feb 15, 2012 12:44 pm    Post subject: Reply with quote

Yes if you gain XP in the game you level up then (as long as you are over the required amount).

I could just leave it and tell the player that they must gain XP normally to level up (which is easy to do in this game), but I would rather know how to do it correctly.

I suppose I could locate some code that executes a lot and do a compare and then JAE in there.

My largest problem right now is that I have never yet been able to track down pointers properly. I have tried many times but for some reason I just fail at that part of it. Most of the tutorials I have been searching through today seem very out of date with missing files and everything. I guess I will keep trying as it shouldn't be that hard once I figure it out.

_________________
---

Too bad my life doesn't have a hex address for suck...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 474

Joined: 09 May 2003
Posts: 25928
Location: The netherlands

PostPosted: Wed Feb 15, 2012 2:45 pm    Post subject: Reply with quote

Pointers in combination of code injection is easier
The code that gives you experience accesses that address. Just do a codeinjection there where you register a symbol and fill the address of that symbol with the address of the experience at that point
Then you can add [ symbolname]+0 as address which will point to your experience

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Nakor
Newbie cheater
Reputation: 0

Joined: 23 Dec 2009
Posts: 22

PostPosted: Wed Feb 15, 2012 6:05 pm    Post subject: Reply with quote

I just put out a +4 trainer for the game. I ended up just telling them they have to gain XP normally in order to level up. I will work on improving it later.

I wanted to click the support cheat engine box but for some reason it doesn't seem to do anything. It just shows an extra blank window. Maybe it's because I'm in Canada or something? The window shows nothing, even if I put a address into the box. It doesn't show my site or your site or an advertisement or anything.

_________________
---

Too bad my life doesn't have a hex address for suck...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 474

Joined: 09 May 2003
Posts: 25928
Location: The netherlands

PostPosted: Thu Feb 16, 2012 1:09 am    Post subject: Reply with quote

Support ce only works if internet explorer is installed. Also in development mode you'll see a different page
_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Nakor
Newbie cheater
Reputation: 0

Joined: 23 Dec 2009
Posts: 22

PostPosted: Thu Feb 16, 2012 11:46 am    Post subject: Reply with quote

I never uninstalled IE but I still see nothing in that window. I see nothing in both developer mode and release.
_________________
---

Too bad my life doesn't have a hex address for suck...
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 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