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 


Disabling one script when another is turned on

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

Joined: 16 Jan 2010
Posts: 121

PostPosted: Sun Mar 18, 2012 11:53 pm    Post subject: Disabling one script when another is turned on Reply with quote

I have two scripts that alter the same instruction address (HP hack)

Please give me hints on how to do it in CE
Back to top
View user's profile Send private message
Kavvman
Master Cheater
Reputation: 2

Joined: 17 Apr 2004
Posts: 316

PostPosted: Mon Mar 19, 2012 4:58 am    Post subject: Reply with quote

In your auto assemble code under the [DISABLE] label put the original game code so when you uncheck the script it will restore the game code back to normal
_________________
...
Back to top
View user's profile Send private message
Freiza
Grandmaster Cheater
Reputation: 22

Joined: 28 Jun 2010
Posts: 662

PostPosted: Mon Mar 19, 2012 6:01 am    Post subject: Reply with quote

make a global variable and assign a value to it, when one script is compared to true activate it or activate the second script.
_________________
Back to top
View user's profile Send private message Send e-mail
lampuiho
Expert Cheater
Reputation: 6

Joined: 16 Jan 2010
Posts: 121

PostPosted: Tue Mar 20, 2012 12:51 am    Post subject: Reply with quote

Freiza wrote:
make a global variable and assign a value to it, when one script is compared to true activate it or activate the second script.


You mean

Code:
cheatcomponent_isActive(CETrainer_CHEAT2)


??

EDIT: Nvm, I think you meant making another auto assembly code to make the global variable to activate the scripts. I don't think I can do it with Lua.

But I have two scripts on the table and I don't know the codes so much to make a single script to include those scripts and the trigger mechanism for the scripts.

Too bad that cheatengine is so limited.

Actually now I think my question was pretty bad because I know how it should do it but I just don't know the codes to make it work.
Back to top
View user's profile Send private message
Freiza
Grandmaster Cheater
Reputation: 22

Joined: 28 Jun 2010
Posts: 662

PostPosted: Tue Mar 20, 2012 10:58 am    Post subject: This post has 1 review(s) Reply with quote

Code:
addresslist = getAddressList()
cheat1= [[description1]]  -- Just put the description of 1st cheat script here.
cheat2= [[description2]]  -- Put the description of 2 cheat script here.
memoryrec1 = addresslist_getMemoryRecordByDescription(addresslist,cheat1)
memoryrec2 = addresslist_getMemoryRecordByDescription(addresslist,cheat2)

memoryrecord_onActivate(memoryrec1,func1)
memoryrecord_onActivate(memoryrec2,func2)

 function func1(memoryrec,before,currentstate)

memoryrecord_unfreeze(memoryrec2)
return true
end

 function func2(memoryrec,before,currentstate)

memoryrecord_unfreeze(memoryrec1)
return true
end


It will set only one cheat at a time. Put the cheat description as mentioned in code.

_________________
Back to top
View user's profile Send private message Send e-mail
lampuiho
Expert Cheater
Reputation: 6

Joined: 16 Jan 2010
Posts: 121

PostPosted: Wed Mar 21, 2012 10:13 pm    Post subject: Reply with quote

Freiza wrote:
Code:
addresslist = getAddressList()
cheat1= [[description1]]  -- Just put the description of 1st cheat script here.
cheat2= [[description2]]  -- Put the description of 2 cheat script here.
memoryrec1 = addresslist_getMemoryRecordByDescription(addresslist,cheat1)
memoryrec2 = addresslist_getMemoryRecordByDescription(addresslist,cheat2)

memoryrecord_onActivate(memoryrec1,func1)
memoryrecord_onActivate(memoryrec2,func2)

 function func1(memoryrec,before,currentstate)

memoryrecord_unfreeze(memoryrec2)
return true
end

 function func2(memoryrec,before,currentstate)

memoryrecord_unfreeze(memoryrec1)
return true
end


It will set only one cheat at a time. Put the cheat description as mentioned in code.


I haven't tried your code but with my code. It does disable the other cheat (not sure if it's just visual) but it does not set the hotkey state. So let's say if one of the hotkeys is F5 and the other is F6. After pressing F5, you press F6 and you deactivate F5 option and activate F6. But next time you press F5 again, you deactivate F6 without turning on F5 because the trainer thinks F5 is still activated.

So my question is, using the generated code, how do I change the hotkey state as well ( I used cheatcomponent_setActive)

EDIT: Nvm, I used memoryrecord_unfreeze as you mentioned and it now looks okay (pressing F5 activates F5 and deactivate F6 visually)

But the script is not actually activated. Why? please

more information:
If the table was opened in CE, manually ticking the checkbox activates the script normally but after executing the script, pressing hotkeys does tick/untick the checkbox but the script does not run unless the checkboxes are ticked manually with the mouse pointer.

EDIT2: I know why now, it deactivates the other only after itself is activated (pressing F6 activates it and then deactivate F5 which is bad because it runs the disable script and turns the code back to original code)
How do I deactivate F5 before F6 is activated?

Code:
function onPostHotkey1(Hotkey)
  --Executed after the "toggle*" cheat got executed
  local memrec=memoryrecordhotkey_getOwner(Hotkey)
  local isActive=memoryrecord_isActive(memrec) --get the state after the hotkey got triggered
  cheatcomponent_setActive(CETrainer_CHEAT1, isActive)
  memoryrecord_unfreeze(memrec313)
  memoryrecord_unfreeze(memrec311)
  if  isActive then
  memoryrecord_freeze(memrec311)
  end
  cheatcomponent_setActive(CETrainer_CHEAT2, false)
  if gBeepOnAction then
    beep()
  end
end

memoryrecordhotkey_onPostHotkey(memrec311_hotkey0,onPostHotkey1)

function onPostHotkey2(Hotkey)
  --Executed after the "toggle*" cheat got executed
  local memrec=memoryrecordhotkey_getOwner(Hotkey)
  local isActive=memoryrecord_isActive(memrec) --get the state after the hotkey got triggered
  cheatcomponent_setActive(CETrainer_CHEAT2, isActive)
  memoryrecord_unfreeze(memrec311)
  memoryrecord_unfreeze(memrec313)
  if  isActive then
  memoryrecord_freeze(memrec313)
  end
  cheatcomponent_setActive(CETrainer_CHEAT1, false)
  if gBeepOnAction then
    beep()
  end
end

memoryrecordhotkey_onPostHotkey(memrec313_hotkey0,onPostHotkey2)


The above code is the temporary solution but it is slow. Hope someone can answer my question in EDIT2: please
Back to top
View user's profile Send private message
Freiza
Grandmaster Cheater
Reputation: 22

Joined: 28 Jun 2010
Posts: 662

PostPosted: Thu Mar 22, 2012 3:05 am    Post subject: Reply with quote

Use memoryrecord_onActivate(memoryrecord, function)
memoryrecord_isActive, because
isActive is tested only after your cheat has been activated.

onActivate is triggered two times, once before your memoryrecord becomes active and one just after it has been activated.

So you can write code that deactivates F5 before F6 is activated if you use onActivate function.

_________________
Back to top
View user's profile Send private message Send e-mail
lampuiho
Expert Cheater
Reputation: 6

Joined: 16 Jan 2010
Posts: 121

PostPosted: Sat Mar 24, 2012 12:45 am    Post subject: Reply with quote

Freiza wrote:
Use memoryrecord_onActivate(memoryrecord, function)
memoryrecord_isActive, because
isActive is tested only after your cheat has been activated.

onActivate is triggered two times, once before your memoryrecord becomes active and one just after it has been activated.

So you can write code that deactivates F5 before F6 is activated if you use onActivate function.


cheers
here is my final code
Code:
function func1(memoryrec,before,currentstate)
if memrec313isActive then
memoryrecord_unfreeze(memrec313)
memrec313isActive=false
  cheatcomponent_setActive(CETrainer_CHEAT2, false)
end
memrec311isActive=currentstate
return true
end

function func2(memoryrec,before,currentstate)
if memrec311isActive then
memoryrecord_unfreeze(memrec311)
memrec311isActive=false
cheatcomponent_setActive(CETrainer_CHEAT1, false)
end
memrec313isActive=currentstate
return true
end
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