Lua CheckBox opcode

R

recadecaz

What is cheating?
Joined
May 23, 2020
Messages
1
Hi! Im new to Cheat Engine Lua Scripting and without guidance from someone I cant seem to make something work...
Here is my Script for the Hotkey using the address (GodsWar.exe+589BC):

CEA:
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here

originalcode:
//.jmp GodsWar.exe+589BC
lea eax,[edi+04]

exit:
jmp returnhere

"GodsWar.exe"+589B7:
jmp newmem
returnhere:



[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
"GodsWar.exe"+589B7:
jmp GodsWar.exe+589BC
lea eax,[edi+04]
//Alt: db EB 03 8D 47 04

Everytime I activate the hotkey, the address was "replaced with a code that does nothing" which in my case disabled the chat log in my game called GodsWar which is my goal to begin with.Now I want to make a trainer as simple as only having a single checkbox in it. Here is my code for the checkbox:

Lua:
function CECheckbox1Change(sender)
if (checkbox_getState(Hacks.CECheckbox1) == 1) then
autoAssemble([[

]])
else
autoAssemble([[

]])
end
end
So I have a working Hotkey command that turns the opcode GodsWar.exe+589B2 into a code that does nothing. Now how can I turn that Hotkey into a CheckBox which turns that opcode into a code that does nothing when activated. Can anyone help me please? :) thank you in advance!
 
TheyCallMeTim13

TheyCallMeTim13

Enchanter
Staff member
Administrator
Fearless Donors
Talents
Joined
Mar 3, 2017
Messages
1,787
So first we can shorten the CEA script to this:
CEA:
[ENABLE]
"GodsWar.exe"+589B7:
    db 90 90
    // nop
    // nop

[DISABLE]
"GodsWar.exe"+589B7:
    db EB 03 // jmp GodsWar.exe+589BC
Then we can add it to the check box on change function like this:
Lua:
function CECheckbox1Change(sender)
    if Hacks.CECheckbox1.Checked then
        autoAssemble([[
"GodsWar.exe"+589B7:
    db 90 90
    // nop
    // nop
        ]])
    else
        autoAssemble([[
"GodsWar.exe"+589B7:
    db EB 03 // jmp GodsWar.exe+589BC
        ]])
    end
end
Then remove the hotkey setup for the memory record if it's not set in a lua script. Then setup a hot with a lua script.
Lua:
function Checkbox1Hotkey()
    Hacks.CECheckbox1.Checked = not Hacks.CECheckbox1.Checked
end
createHotkey('Checkbox1Hotkey', VK_NUMPAD1)
So now the hotkey checks or unchecks the checkbox, and the checkbox NOPs (no operation) the code and restores the original code based on if it's checked or unchecked. You can find the "defines.lua" file in the Cheat Engine directory for a list of the virtual keys variables to use with the createHotkey function.
 
Last edited:
Top