|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
makataurugami How do I cheat? Reputation: 0
Joined: 21 Apr 2017 Posts: 7
|
Posted: Fri Apr 21, 2017 6:58 am Post subject: Problem in scripting with already existent adresses... |
|
|
Man, i has stuck!
Well, i started programming with cheat engine recently and i want create script to change adresses already defined, in the adress list.
For example, i have 100 gold and 5 strength. I find the gold, strenght adress and i create a point adress. Now, every time when i start the game the research for gold and strength is not needed, this thing is ok, but how i use already searched point adress like a variable in my script?
And next, i want create a new thing: Every time if i have 100 gold, i earn 1 strenght and my gold turns 0.
How i do this?
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Fri Apr 21, 2017 7:46 am Post subject: |
|
|
Since you're asking in the lua scripting section I'll focus on that.
Most lua functions take an address, so if it's a pointer like "game.exe+550" with an offset of 4 and an offset of 8 (or a static address, just want to demonstrate multilevel pointers) then you can can use something like this as the address "[[game.exe+550]+4]+8" (the [] tell lua to read the value at that address in memory as an address/pointer before continuing), eg.
Code: | [ENABLE]
{$lua} -- switch parser to lua instead of assembly
writeInteger("[[game.exe+550]+4]+8", 100) -- write 100 to address given
-- note any string returned will be parsed as if it was code in the asm script
{$asm} // switch back to assembly parser
[DISABLE]
// do nothing
|
So to change 100 gold into 1 strength you could do something like this:
Code: | [ENABLE]
{$lua}
goldAddr = address of gold
strAddr = address of strength
gold = readInteger(goldAddr)
-- assuming 4 byte values, aka "integer"
if gold > 100 then
writeInteger(goldAddr, gold-100)
writeInteger(strAddr, readInteger(strAddr)+1)
end
{$asm}
[DISABLE] |
If you want it to happen automatically instead of having to enable the script every time then you could create a timer eg.
Code: | [ENABLE]
{$lua}
goldAddr = address of gold
strAddr = address of strength
mr = getAddressList().getMemoryRecordByDescription("name/description of script")
timer = createTimer()
-- set code to run
timer.OnTimer = function(timer)
-- check if the script has been disabled
if not mr.Active then
timer.destroy() -- stop the timer
return -- don't execute the rest of this code
end
-- script still enabled so read gold value
-- assuming 4 byte values, aka "integer"
gold = readInteger(goldAddr)
-- check if gold is greater than or equal to 100
if gold >= 100 then
-- subtract 100 from gold amount and increase strength amount by 1
writeInteger(goldAddr, gold-100)
writeInteger(strAddr, readInteger(strAddr)+1)
end
end
-- set time delay between code being run
timer.Interval = 1000 -- 1000 milliseconds / second, so every second
{$asm}
[DISABLE] |
|
|
Back to top |
|
|
makataurugami How do I cheat? Reputation: 0
Joined: 21 Apr 2017 Posts: 7
|
Posted: Fri Apr 21, 2017 3:11 pm Post subject: Wow |
|
|
Thank you soo much, now i can continue my mod, good luck!
|
|
Back to top |
|
|
|
|
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
|
|