View previous topic :: View next topic |
Author |
Message |
ZxPwds Advanced Cheater Reputation: 0
Joined: 27 Oct 2015 Posts: 59
|
Posted: Wed Jun 23, 2021 6:13 pm Post subject: [HELP] Creating a hotkey for toggling scripts |
|
|
Ok so I created a thread a while back where I had someone very kind enough to help me through a working hotkey
for my trainers, and for years I've been using it. But it has glitchy moments, Where It wont actually register the fact that
I am pushing ALT + [KEY] and just other things I'm not able to really explain. I was wondering if anybody had a better way
to create a hotkey and to toggle on and off an AA script.
Code: |
toggleGunLock = false
function toggleGunLock()
toggleGunLock = not toggleGunLock
if toggleGunLock then
playSound(findTableFile('Activate'))
AddressList.getMemoryRecordByDescription("#GunLock").Active = true
Form1.cheatGunLock.Font.Color=0x00ff00
else
AddressList.getMemoryRecordByDescription("#GunLock").Active = false
playSound(findTableFile('Deactivate'))
Form1.cheatGunLock.Font.Color=0xffffff
end
end
if kGunLock and kGunLock.destroy then
kGunLock.destroy()
end
kGunLock = nil
kGunLock = createHotkey(toggleGunLock,VK_LMENU, 0x47) -- ALT + G)
kGunLock.DelayBetweenActivate = 1000
|
Does anybody have a way to do what I'm doing but differently?
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Wed Jun 23, 2021 6:49 pm Post subject: |
|
|
Look at the "celua.txt" file in the CE directory. Look up the MemoryRecordHotkey class and MemoryRecord class. Use the MemoryRecord classes "createHotkey" instead of the generic one. This way you don't have to create a seperate thread. And can just let CE handle it, this has the added benefit of whatever CE settings they have for hotkey intervals and what not will be used. And it has properties for the things you are doing manually, like with the sound file.
EDIT:
You can use "OnPostHotkey" to update the UI.
_________________
|
|
Back to top |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Mon Jun 28, 2021 6:57 am Post subject: |
|
|
I would do like this;
Code: | toggleGunLock = 0 -- or false
function toggleGunLock()
if toggleGunLock==0 then
playSound(findTableFile('Activate'))
AddressList.getMemoryRecordByDescription("#GunLock").Active = true
Form1.cheatGunLock.Font.Color=0x00ff00
toggleGunLock=1
else
AddressList.getMemoryRecordByDescription("#GunLock").Active = false
playSound(findTableFile('Deactivate'))
Form1.cheatGunLock.Font.Color=0xffffff
toggleGunLock=0
end
end
if kGunLock then kGunLock.destroy() kGunLock = nil end
kGunLock = createHotkey(toggleGunLock,VK_LMENU, 0x47) -- ALT + G)
kGunLock.DelayBetweenActivate = 1000 |
|
|
Back to top |
|
|
|