|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Autem Expert Cheater Reputation: 1
Joined: 30 Jan 2023 Posts: 118
|
Posted: Mon May 08, 2023 5:45 am Post subject: Lua script hotkey refuses to disable |
|
|
I've run into this problem a few times and then I find what I think is a solution, then months later the problem is back, so I guess I didn't find it (again lol). Can someone please tell me what is the official 100% guaranteed way to make a lua script DISABLE its hotkeys when you deactivate it? I thought I solved this a couple different times and it's back again so I have no idea what's going on. Any help on a definite, final solution that will stick would be greatly appreciated.
Right now as it stands, this script's hotkeys won't disable. Even if I close Cheat Engine and restart it, the hotkey Q+A is somehow still active even without me turning the script back on. Sometimes it even starts executing 2+ times just from one hotkey press. It's almost like multiple versions of it get kept in memory and overlap or something.
Code: | [enable]
{$lua}
if syntaxcheck then return end
function func3(sender)
print('pausing the game to prepare for AOB scan..............................................')
pause()
local scan = '0 0 0 0 0 * 0 * * 0 * * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 * * * * 64 64 64 64 64 0 0', '+W-X-C';
local data = AOBScan(scan);
if (data) then
local count = data.getCount();
for i=0, count-1 do
local address = data.getString(i);
writeBytes(tonumber(address,16)+6, 0x04)
end
print('Assigned two ppl to team 2')
end
local scan = '0 0 0 0 0 * 3 * * 0 * * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 * * * * 64 64 64 64 64 0 0', '+W-X-C';
local data = AOBScan(scan);
if (data) then
local count = data.getCount();
for i=0, count-1 do
local address = data.getString(i);
writeBytes(tonumber(address,16)+6, 0x01)
end
print('Assigned two ppl to team 1')
end
local scan = '0 0 0 0 0 * 2 * * 0 * * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 * * * * 64 64 64 64 64 0 0', '+W-X-C';
local data = AOBScan(scan);
if (data) then
local count = data.getCount();
for i=0, count-1 do
local address = data.getString(i);
writeBytes(tonumber(address,16)+6, 0x04)
end
print('Assigned another to finish team 2')
end
local scan = '0 0 0 0 0 * 5 * * 0 * * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 * * * * 64 64 64 64 64 0 0', '+W-X-C';
local data = AOBScan(scan);
if (data) then
local count = data.getCount();
for i=0, count-1 do
local address = data.getString(i);
writeBytes(tonumber(address,16)+6, 0x01)
end
print('Assigned another to finish team 1')
end
print('SHOULD BE FINISHED. PLEASE RESTART THE MATCH NOW.')
unpause()
return true
end
hkey=createHotkey("func3",VK_A,VK_Q)
[disable]
{$lua}
if syntaxcheck then return end
hkey.destroy()
function func3(sender)
return true
end
|
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1053 Location: 0x90
|
Posted: Mon May 08, 2023 9:05 am Post subject: Re: Lua script hotkey refuses to disable |
|
|
Autem wrote: | I've run into this problem a few times and then I find what I think is a solution, then months later the problem is back, so I guess I didn't find it (again lol). Can someone please tell me what is the official 100% guaranteed way to make a lua script DISABLE its hotkeys when you deactivate it? I thought I solved this a couple different times and it's back again so I have no idea what's going on. Any help on a definite, final solution that will stick would be greatly appreciated.
Right now as it stands, this script's hotkeys won't disable. Even if I close Cheat Engine and restart it, the hotkey Q+A is somehow still active even without me turning the script back on. Sometimes it even starts executing 2+ times just from one hotkey press. It's almost like multiple versions of it get kept in memory and overlap or something.
|
I would recommend against using the same variable names for different variables. But, perhaps this will help:
Code: |
[ENABLE]
{$LUA}
if syntaxcheck then return end
function func3()
print('pausing the game to prepare for AOB scan..............................................')
pause()
local scan1 = '0 0 0 0 0 * 0 * * 0 * * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 * * * * 64 64 64 64 64 0 0', '+W-X-C';
local data1 = AOBScan(scan1);
if (data1) then
local count = data1.getCount();
for i=0, count-1 do
local address = data1.getString(i);
writeBytes(tonumber(address,16)+6, 0x04)
end
print('Assigned two ppl to team 2')
end
local scan2 = '0 0 0 0 0 * 3 * * 0 * * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 * * * * 64 64 64 64 64 0 0', '+W-X-C';
local data2 = AOBScan(scan2);
if (data2) then
local count = data2.getCount();
for i=0, count-1 do
local address = data2.getString(i);
writeBytes(tonumber(address,16)+6, 0x01)
end
print('Assigned two ppl to team 1')
end
local scan3 = '0 0 0 0 0 * 2 * * 0 * * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 * * * * 64 64 64 64 64 0 0', '+W-X-C';
local data3 = AOBScan(scan3);
if (data3) then
local count = data3.getCount();
for i=0, count-1 do
local address = data3.getString(i);
writeBytes(tonumber(address,16)+6, 0x04)
end
print('Assigned another to finish team 2')
end
local scan4 = '0 0 0 0 0 * 5 * * 0 * * 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 * * * * 64 64 64 64 64 0 0', '+W-X-C';
local data4 = AOBScan(scan4);
if (data4) then
local count = data4.getCount();
for i=0, count-1 do
local address = data4.getString(i);
writeBytes(tonumber(address,16)+6, 0x01)
end
print('Assigned another to finish team 1')
end
print('SHOULD BE FINISHED. PLEASE RESTART THE MATCH NOW.')
unpause()
end
local keys = {VK_A, VK_Q}
hkey = createHotkey(func3, keys)
[DISABLE]
{$LUA}
if syntaxcheck then return end
if hkey then hkey.destroy(); hkey = nil end
|
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Mon May 08, 2023 10:56 am Post subject: |
|
|
Autem wrote: | Even if I close Cheat Engine and restart it, the hotkey Q+A is somehow still active even without me turning the script back on. | Nothing in that script could cause this to happen.
"hkey" isn't very descriptive for a global variable name. You also don't account for the case where the script gets disabled without executing the disable section.
Code: | {$lua}
if syntaxcheck or not memrec then return end
if myUniqueHotkeyName then
myUniqueHotkeyName.destroy();
myUniqueHotkeyName = nil
end
[ENABLE]
local function on_hotkey(hk)
if not memrec.Active then
return
end
--...
end
myUniqueHotkeyName = createHotkey(on_hotkey, VK_A, VK_Q)
[DISABLE]
-- hk destroyed above
|
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Autem Expert Cheater Reputation: 1
Joined: 30 Jan 2023 Posts: 118
|
Posted: Mon May 08, 2023 11:43 am Post subject: |
|
|
Thanks both of you for the help. I think I've got it working now! So far so good, anyway. :)
|
|
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
|
|