 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
zw443 How do I cheat?
Reputation: 0
Joined: 09 Aug 2018 Posts: 5
|
Posted: Wed Jun 19, 2019 9:52 am Post subject: Sleep without pausing entire form? |
|
|
I'm trying to make my trainer auto close with a label displaying how long it has left to close, as well as an option to exit before the time is up.
However, when I sleep(1000) 30 times, it waits 30 seconds and closes. But it prevents the user to click the exit button sooner and locks all the controls.
Here's what I have tried so far; | Code: | for loop = 1, 30 do
sleep(1000)
label.Caption = 30 - loop
end |
| Code: | local start, time = getTickCount()
for loop = 1, 30 do
time = getTickCount() - start
while time < 1000 do
time = getTickCount() - start
sleep(1)
end
end |
| Code: | label.Caption = "Closes in 30 seconds."
sleep(30000) |
If it's impossible, that's ok.
|
|
| Back to top |
|
 |
Lynxz Gaming Expert Cheater
Reputation: 4
Joined: 01 Jul 2017 Posts: 208 Location: help
|
Posted: Wed Jun 19, 2019 10:08 am Post subject: Re: Sleep without pausing entire form? |
|
|
| zw443 wrote: | I'm trying to make my trainer auto close with a label displaying how long it has left to close, as well as an option to exit before the time is up.
However, when I sleep(1000) 30 times, it waits 30 seconds and closes. But it prevents the user to click the exit button sooner and locks all the controls.
Here's what I have tried so far; | Code: | for loop = 1, 30 do
sleep(1000)
label.Caption = 30 - loop
end |
| Code: | local start, time = getTickCount()
for loop = 1, 30 do
time = getTickCount() - start
while time < 1000 do
time = getTickCount() - start
sleep(1)
end
end |
| Code: | label.Caption = "Closes in 30 seconds."
sleep(30000) |
If it's impossible, that's ok. |
try with createNativeThread
| Code: | createNativeThread(function()
for loop = 1, 30 do
sleep(1000)
label.Caption = 30 - loop
end
end) |
| Code: | createNativeThread(function()
local start, time = getTickCount()
for loop = 1, 30 do
time = getTickCount() - start
while time < 1000 do
time = getTickCount() - start
sleep(1)
end
end
end) |
| Code: | createNativeThread(function()
label.Caption = "Closes in 30 seconds."
sleep(30000)
end) |
_________________
my english is bad
discord : rynx#9828 |
|
| Back to top |
|
 |
zw443 How do I cheat?
Reputation: 0
Joined: 09 Aug 2018 Posts: 5
|
Posted: Wed Jun 19, 2019 10:14 am Post subject: |
|
|
Thank you so much!
This works as I want it to.
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Thu Jun 20, 2019 1:32 pm Post subject: |
|
|
Using threads for a simple task is overkill and huge waste of resources, why use a loop when you could just use a simple timer?
| Code: | form = createForm();
label = createLabel(form);
-- create timer;
t = createTimer(label);
t.Interval = 100; -- 10 times/sec;
local getCaption = function(t) return ('%d seconds until shutdown'):format(t); end;
-- start timestamp, timeout time in seconds
local start,timeout = os.clock(),30;
label.Caption = getCaption(timeout); -- set starting caption
t.onTimer = function (sender)
local ts = timeout - (os.clock()-start)//1; -- round down; returns float so we use string.format
label.Caption = getCaption(ts); -- update caption;
if (ts <= 0) then -- condition met, shut down;
print('shut down');
label.destroy(); -- destroying the label will also destroy this timer;
-- sender.destroy() -- alternative destroy this timer;
-- closeCE(); -- shut down;
end
end
|
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| 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
|
|