View previous topic :: View next topic |
Author |
Message |
Tum Cheater Reputation: 0
Joined: 10 Jan 2010 Posts: 28
|
Posted: Sat May 06, 2017 8:17 am Post subject: Creating Trainers ? |
|
|
Hi,
Is there anyway i can add more than one function to a single hotkey when creating a trainer.
I would like to have one press change the value of an address, then freeze the address.
At the moment, am having to have one hotkey change the value, then another hotkey freeze the value in the address.
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Sat May 06, 2017 8:44 am Post subject: |
|
|
Sure, just save it as a ct and then open it and edit the lua script (Table->"Show Cheat Table Lua Script").
It'll look something like this:
Code: | --TRAINERGENERATORSTART--
--This is autogenerated code. Changing code in this block will
--get erased and rewritten if you regenerate the trainer code
--Uncomment the following line if this is a Cheat Table format trainer and you don't want CE to show (Tip, save as .CETRAINER alternatively)
--hideAllCEWindows()
RequiredCEVersion=6.6
if (getCEVersion==nil) or (getCEVersion()<RequiredCEVersion) then
messageDialog('Please install Cheat Engine '..RequiredCEVersion, mtError, mbOK)
closeCE()
end
addresslist=getAddressList()
memrec194=addresslist.getMemoryRecordByID(194)
memrec194_hotkey0=memrec194.getHotkeyByID(0)
memrec194_hotkey1=memrec194.getHotkeyByID(1)
function onPostHotkey0(Hotkey)
--Executed after the "toggle*" cheat got executed
local memrec=Hotkey.Owner
local isActive=memrec.Active --get the state after the hotkey got triggered
CETrainer.CHEAT0.setActive(isActive) --gui update, nothing else
if gPlaySoundOnAction then
if isActive then
playSound(gActivateSound)
else
playSound(gDeactivateSound)
end
end
end
memrec194_hotkey0.onPostHotkey=onPostHotkey0
function onHotkey1(Hotkey)
--Executed before the hotkey is handled
CETrainer.CHEAT1.setActive(true, 1500)
if gPlaySoundOnAction then
playSound(gActivateSound)
end
end
memrec194_hotkey1.onHotkey=onHotkey1
CETrainer.SEPERATOR.Visible=false
getAutoAttachList().add("Tutorial-i386.exe")
gPlaySoundOnAction=false
CETrainer.show()
function AboutClick()
showMessage(gAboutText)
end
gAboutText=[[This trainer was made by Cheat Engine
www.cheatengine.org]]
function CloseClick()
--called by the close button onClick event, and when closing the form
closeCE()
return caFree --onClick doesn't care, but onClose would like a result
end
--TRAINERGENERATORSTOP-- |
Figure out which hotkey is the one you want to press, I'll use hotkey0 (the one that freezes the value) and which hotkey you want it to execute at the same time (in this case hotkey1 is the only other hotkey) and add memrec194_hotkey1.doHotkey() inside of it's code. Then, if you want, you can remove any keys for the hotkey so that it can't be activated on it's own and edit the form so that it doesn't show.
|
|
Back to top |
|
|
Tum Cheater Reputation: 0
Joined: 10 Jan 2010 Posts: 28
|
Posted: Sat May 06, 2017 12:00 pm Post subject: |
|
|
Thanks you.
Finally got the trainer completed, and compiled after a little bit of messing around.
I didnt see how to remove the hotkeys though so they dont accidentally get pressed.
I dont know much about lua
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Sat May 06, 2017 1:24 pm Post subject: |
|
|
Tum wrote: | I didnt see how to remove the hotkeys though so they dont accidentally get pressed. | Go back to where you create the hotkeys, select the one you want to edit, and click "clear" next to the keys input
|
|
Back to top |
|
|
Tum Cheater Reputation: 0
Joined: 10 Jan 2010 Posts: 28
|
Posted: Sat May 06, 2017 3:24 pm Post subject: |
|
|
Thanks a lot
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Sat May 06, 2017 4:38 pm Post subject: |
|
|
No problem, it's not something I've done before since I don't usually bother with trainers myself so it was interesting to spend a few minutes figuring it out (I had a clue it'd be in the lua script)
|
|
Back to top |
|
|
Tum Cheater Reputation: 0
Joined: 10 Jan 2010 Posts: 28
|
Posted: Tue May 09, 2017 10:34 am Post subject: |
|
|
How do i go about writing to cheats in my cheat engine list.
I have a static pointer as the first entry in my cheat engine address list.
I know that that is register 0
So would i enter in my togglebox event section the following, as i want it to freeze the address after changing the value.
Quote: |
if (checkbox_getState(UDF1.CECheckbox1) == 1) then
CheatEntry=addresslist_getMemoryRecordByID(addresslist,0)
writeFloat((CheatEntry), 6000)
memoryrecord_freeze(CheatEntry)
else
CheatEntry=addresslist_getMemoryRecordByID(addresslist,0)
memoryrecord_unfreeze(CheatEntry)
end
|
I want 6000 entering into the address of the first address on my address list in cheat engine. It is a float.
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Tue May 09, 2017 10:47 am Post subject: |
|
|
That's the older style before DB changed the objects to let you access the functions from the objects theirselves (so it looks like OOP code)
Code: |
CheatEntry = addresslist.getMemoryRecord(0)
-- if you're getting it based on the position / index then use this
-- ID is a number that is incremented every time a record is created
-- it is unique for every record, and does not change like position/description
-- you can use http://forum.cheatengine.org/viewtopic.php?t=602420 to find the ID
-- or simply open the cheat table in a text editor (it's an xml file)
if UDF1.CECheckbox1.Checked then
CheatEntry.Value = "6000" -- or writeFloat(CheatEntry.Address, 6000)
CheatEntry.Active = true -- activate script / freeze value
else
CheatEntry.Active = false -- unfreeze
end |
|
|
Back to top |
|
|
Tum Cheater Reputation: 0
Joined: 10 Jan 2010 Posts: 28
|
Posted: Tue May 09, 2017 12:16 pm Post subject: |
|
|
Thanks again for the help.
I have tried using what you said, but no matter how adapt it, i constantly get an error message when i press the togglebox on my trainer.
This is the error i keep getting, but dont understand why?
Quote: | Error:[string "RequiredCEVersion=6.6
..."]:23: attempt to index a nil value (field 'CECheckBox1') |
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Tue May 09, 2017 1:54 pm Post subject: |
|
|
Quote: | attempt to index a nil value (field 'CECheckBox1') |
Then CECheckBox1 isn't the name of your check box, open your form in the editor and check what name you gave it.
|
|
Back to top |
|
|
Tum Cheater Reputation: 0
Joined: 10 Jan 2010 Posts: 28
|
Posted: Tue May 09, 2017 2:18 pm Post subject: |
|
|
Ye i tried changing that.
Am using togglebox, so i changed the entry to CEToggleBox1 which is the name of the actually box.
But that then gives me a different error.
Quote: | Error:[string "RequiredCEVersion=6.6
..."]:24: attempt to index a nil value (global 'addresslist') |
So i cant see what else am doing wrong.
This is the section of the script.
Quote: | function CEToggleBox1Click(sender)
if UDF1.CEToggleBox1.Checked then
CheatEntry = addresslist.getMemoryRecord(0)
CheatEntry.Value = "6000" -- or writeFloat(CheatEntry.Address, 6000)
CheatEntry.Active = true -- activate script / freeze value
else
CheatEntry.Active = false -- unfreeze
end
end |
I was thinking of just trying adding the address, but it has 6 offsets, so not sure how to add that.
And anyway, shouldnt it work using the cheat table like am trying ?
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Tue May 09, 2017 3:00 pm Post subject: |
|
|
Quote: | attempt to index a nil value (global 'addresslist') | then you haven't set the addresslist variable via Code: | addresslist = getAddressList() | not sure why CE doesn't set addresslist automatically like the forms (eg. UDF1) since you're almost certainly going to use it but it doesn't so...
|
|
Back to top |
|
|
Tum Cheater Reputation: 0
Joined: 10 Jan 2010 Posts: 28
|
Posted: Tue May 09, 2017 4:09 pm Post subject: |
|
|
Nice 1, thanks a lot, that worked.
|
|
Back to top |
|
|
|