 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Dread Pony Roberts How do I cheat?
Reputation: 0
Joined: 12 Dec 2018 Posts: 6
|
Posted: Wed Dec 19, 2018 7:46 pm Post subject: [SOLVED] Need help creating a press and hold hotkey toggle. |
|
|
I'm trying to create a fly script and I want to be able to fly up when space is pressed and held, fly down when left control is held down, and stay level when nothing is pressed.
Example, when nothing is pressed
| Code: | code:
//mov [ebx+2C],ecx
test dl,01
jmp return |
When space is pressed
| Code: | code:
//mov [ebx+2C],ecx
add [ebx+2C],FFF
test dl,01
jmp return |
When left control is pressed
| Code: | code:
//mov [ebx+2C],ecx
sub [ebx+2C],FFF
test dl,01
jmp return |
And here is my original script in case it helps
| Code: | [ENABLE]
aobscanmodule(Y_COORDINATE_LOCK,Df.exe,89 4B 2C F6 C2 01) // should be unique
alloc(newmem,$1000)
label(code)
label(return)
newmem:
cmp [ebx+08],00
jne code
//mov [ebx+2C],ecx
add [ebx+2C],FFF
test dl,01
jmp return
code:
mov [ebx+2C],ecx
test dl,01
jmp return
Y_COORDINATE_LOCK:
jmp newmem
nop
return:
registersymbol(Y_COORDINATE_LOCK)
[DISABLE]
Y_COORDINATE_LOCK:
db 89 4B 2C F6 C2 01
unregistersymbol(Y_COORDINATE_LOCK)
dealloc(newmem) |
I'm new to lua code but I was hoping if there was one I could use in multiple scripts in multiple games to achieve the same effect.
Thank you. _________________
How fair is it that you are the only one with a One Hit Kill? What if the AI had just as much power? That would definitely make the gameplay a bit more...EXTREME!
Last edited by Dread Pony Roberts on Sat Dec 22, 2018 8:22 am; edited 1 time in total |
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4719
|
Posted: Wed Dec 19, 2018 8:56 pm Post subject: |
|
|
You could store a variable in your code injection that's modified by CE. See what value it is to do what you want. e.g.:
| Code: | [ENABLE]
{$lua}
if syntaxcheck then return end
if t then t.destroy(); t = nil end
local lastVal = 0
t = createTimer()
t.Interval = 100
t.OnTimer = function(t)
local addr = getAddressSafe'direction'
if addr then
local newVal
if isKeyPressed(VK_SPACE) then -- up
newVal = 1
elseif isKeyPressed(VK_LCONTROL) then -- down
newVal = 2
-- etc...
else
newVal = 0
end
if newVal ~= lastVal and writeInteger(addr, newVal) then
lastVal = newVal
end
end
end
{$asm}
alloc(direction,4)
registersymbol(direction)
//...
direction:
dd 0 // 0 = none, 1 = up, 2 = down, ...
code:
mov eax,[direction]
cmp eax,0
jne short @f
// original code
jmp exit
@@:
cmp eax,1
jne short @f
// go up
jmp exit
@@:
cmp eax,2
// etc...
exit:
// clean up
jmp return
[DISABLE]
{$lua}
if t then t.destroy; t = nil end
{$asm}
dealloc(direction)
unregistersymbol(direction)
// etc... |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Dread Pony Roberts How do I cheat?
Reputation: 0
Joined: 12 Dec 2018 Posts: 6
|
Posted: Sat Dec 22, 2018 1:25 am Post subject: |
|
|
Thanks, it crashed but I found another solution.
I tried adapting your code to my script, here's what I got.
| Code: | [ENABLE]
{$lua}
if syntaxcheck then return end
if t then t.destroy(); t = nil end
local lastVal = 0
t = createTimer()
t.Interval = 100
t.OnTimer = function(t)
local addr = getAddressSafe'direction'
if addr then
local newVal
if isKeyPressed(VK_SPACE) then -- up
newVal = 1
elseif isKeyPressed(VK_LCONTROL) then -- down
newVal = 2
-- etc...
else
newVal = 0
end
if newVal ~= lastVal and writeInteger(addr, newVal) then
lastVal = newVal
end
end
end
{$asm}
aobscanmodule(Z_COORDINATE_LOCK,Df.exe,89 4B 2C F6 C2 01) // should be unique
alloc(newmem,$1000)
alloc(direction,4)
registersymbol(direction)
label(code)
label(return)
label(oldcode)
newmem:
direction:
dd 0
code:
cmp [ebx+08],00
jne oldcode
push eax
mov eax,[direction]
cmp eax,0
jne short @f
pop eax
//mov [ebx+2C],ecx
test dl,01
jmp return
@@:
cmp eax,1
jne short @f
pop eax
//mov [ebx+2C],ecx
add [ebx+2C],FFF
test dl,01
jmp return
@@:
pop eax
//mov [ebx+2C],ecx
sub [ebx+2C],FFF
test dl,01
jmp return
oldcode:
pop eax
mov [ebx+2C],ecx
test dl,01
jmp return
Z_COORDINATE_LOCK:
jmp newmem
nop
return:
registersymbol(Z_COORDINATE_LOCK)
[DISABLE]
Z_COORDINATE_LOCK:
db 89 4B 2C F6 C2 01
{$lua}
if t then t.destroy(); t = nil end
{$asm}
dealloc(direction)
unregistersymbol(direction)
unregistersymbol(Z_COORDINATE_LOCK)
dealloc(newmem) |
As previously mentioned, it crashed on me.
But after much research, I managed to find an alternative that workes.
| Code: | [ENABLE]
aobscanmodule(Z_COORDINATE_LOCK,Df.exe,89 4B 2C F6 C2 01) // should be unique
alloc(newmem,$1000)
label(code)
label(return)
label(lower)
label(hover)
newmem:
cmp [ebx+08],00
jne code
pushad
pushfd
push 26
call GetAsyncKeystate
shr ax,#15
cmp ax,1
jne lower
popfd
popad
//mov [ebx+2C],ecx
add [ebx+2C],FFF
test dl,01
jmp return
lower:
push 28
call GetAsyncKeystate
shr ax,#15
cmp ax,1
jne hover
popfd
popad
//mov [ebx+2C],ecx
sub [ebx+2C],FFF
test dl,01
jmp return
hover:
popfd
popad
//mov [ebx+2C],ecx
test dl,01
jmp return
code:
mov [ebx+2C],ecx
test dl,01
jmp return
Z_COORDINATE_LOCK:
jmp newmem
nop
return:
registersymbol(Z_COORDINATE_LOCK)
aobscanmodule(LOCK_GROUND,Df.exe,80 4B 6D 20 E9 DC FB FF FF) // should be unique
alloc(newmemw,$1000)
label(codew)
label(returnw)
newmemw:
codew:
//or byte ptr [ebx+6D],20
jmp Df.exe+877DE
jmp returnw
LOCK_GROUND:
jmp newmemw
nop
nop
nop
nop
returnw:
registersymbol(LOCK_GROUND)
[DISABLE]
Z_COORDINATE_LOCK:
db 89 4B 2C F6 C2 01
unregistersymbol(Z_COORDINATE_LOCK)
dealloc(newmem)
LOCK_GROUND:
db 80 4B 6D 20 E9 DC FB FF FF
unregistersymbol(LOCK_GROUND)
dealloc(newmemw) |
I think the problem was that I couldn't figure out what to google and I thought lua was the answer. Sorry if I wasted your time, I did at least learn a bit more on lua in case I actually need it in the future.
Thank you. _________________
How fair is it that you are the only one with a One Hit Kill? What if the AI had just as much power? That would definitely make the gameplay a bit more...EXTREME! |
|
| 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
|
|