View previous topic :: View next topic |
Author |
Message |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Fri Apr 19, 2013 6:52 am Post subject: Hotkeys.. |
|
|
Couldn't doubt post in the last thread so making a new one.
I have made hotkeys for quick stats changing.
how can I enable/disable hotkeys usage, or destroy&re-create them when user opens some menu or editing editbox text?
Code: |
function test()
print(1)
object_destroy(a)
end
a = createHotkey(test,VK_1) |
This does not work, it causes C.E to freeze
or is there any way to do so without using timers? (checking if hotkey is pressed).
I don't want to slow down the game, using multiply timers makes the game/PC sometimes to freeze (I made few weeks ago an teleport hack which makes game to freeze for few seconds after few minutes)
_________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
Gniarf Grandmaster Cheater Supreme
Reputation: 43
Joined: 12 Mar 2012 Posts: 1285
|
Posted: Fri Apr 19, 2013 7:53 am Post subject: |
|
|
Something like that:
Code: | HotKey1Enabled = true;
function test()
if (HotKey1Enabled) then
print(1)
HotKey1Enabled = false;
end
end
createHotkey(test,VK_1) |
And don't forget to set HotKey1Enabled to true "when user opens some menu or [edits] editbox text".
|
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Fri Apr 19, 2013 8:32 am Post subject: |
|
|
Will I be able to destroy it?
My project loads lua extensions from my server, and runs the trainers.
But user will be able to open multiply trainers, so I don't want that hotkeys will get messed up.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
Gniarf Grandmaster Cheater Supreme
Reputation: 43
Joined: 12 Mar 2012 Posts: 1285
|
Posted: Fri Apr 19, 2013 9:33 am Post subject: |
|
|
Flash hacker wrote: | Will I be able to destroy it? | Nope (erm, unless you close CE).
If you want to handle the deallocation I suggest keeping track of all created hotkeys in an array, and freeing the hotkey array when initializing a new trainer, like in the example below.
I requires that you keep the same name for the hotkey array in all trainers.
Code: | --declare the hotkey array of needed
if (HotKeys==nil) then
HotKeys={}
end
--deallocate hotkeys if any
function ClearHotkeys()
print("We had "..table.getn(HotKeys).." hotkeys")
if (HotKeys~=nil) then
for i=0 , table.getn(HotKeys) do
object_destroy(HotKeys[i]);
HotKeys[i]=nil;
end
end
end
ClearHotkeys(); --call that when initializing a new trainer
--register new hotkeys
function HotKey_VK_1()
print(1)
end
HotKeys[table.getn(HotKeys)+1]=createHotkey(HotKey_VK_1,VK_1); |
Aside that, I don't see why you'd want to have, and don't recommend having a hotkey self-destroy. If you somehow need it to work only once, use an enable/disable flag instead.
|
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Fri Apr 19, 2013 9:46 am Post subject: |
|
|
Looks good, thanks.
And I need it to work until closed.
There some game and I edit skill stats, I don't find anything&anyhow to cmp with (Its an flash game), so I use hotkeys to tweak between damage values,
But I also need these hotkeys for teleport trainers.
when user closes the trainer I disable scripts (dealloc) and destroy the scripts. (object_destroy .. ).
So if the hotkey will remain, it will try to write into not-vaild address an value.
Which will result in LUA engine errors.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
|