|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Fri Dec 30, 2016 9:09 pm Post subject: Custom function for timer.performWithDelay() |
|
|
Hi,
I try making a countdown timer using lua.
Code: | local secondsLeft = 1.2 * 60 --- 1 minutes 20 seconds
local clockText = "01:20"
t=createTimer(nil)
t.Interval=1000
t.OnTimer=function(t)
secondsLeft = secondsLeft - 1
-- time is tracked in seconds. We need to convert it to minutes and seconds
local minutes = math.floor( secondsLeft / 60 )
local seconds = secondsLeft % 60
if minutes == 0 and seconds == 0 then t.Enabled=false end
-- make it a string using string format.
local timeDisplay = string.format( "%02d:%02d", minutes, seconds )
clockText = timeDisplay
print(tostring(clockText))
end
t.Enabled=true
|
in CoronaLab has a function :
Code: | local secondsLeft = 1.2 * 60 --- 1 minutes 20 seconds
local clockText = "01:20"
local function updateTime()
-- decrement the number of seconds
secondsLeft = secondsLeft - 1
-- time is tracked in seconds. We need to convert it to minutes and seconds
local minutes = math.floor( secondsLeft / 60 )
local seconds = secondsLeft % 60
-- make it a string using string format.
local timeDisplay = string.format( "%02d:%02d", minutes, seconds )
clockText.text = timeDisplay
print(tostring(clockText))
end
local countDownTimer = timer.performWithDelay( 1000, updateTime, secondsLeft )
|
Can some lua masters make custom function or (maybe a lib) for "timer.performWithDelay( delay, listener [, iterations] )" in pure lua ?.
Thank you
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Fri Dec 30, 2016 10:56 pm Post subject: |
|
|
The only thing CE's timer doesn't have is the iterations.
That's easy enough to do, why complicate things with an extra function?
Code: | local iterations = 10
local timer = createTimer(nil, false)
timer.Interval = 1000
timer.OnTimer = function(timer)
print(os.date("!%M:%S", iterations)) -- your code here
iterations = iterations - 1
if iterations <= 0 then timer.Enabled = false end
end
timer.Enabled = true |
By the way, 1.2 * 60 == 72 (1 minute, 12 seconds).
...but if you must
Code: | function doThis(timer, iteration)
print("["..iteration.."] a little bit of this")
end
function doThat(timer, iteration)
print("["..iteration.."] a little bit of that")
end
function performWithDelay(delay, listener, iterations)
if type(delay) ~= "number" then return end
if type(listener) ~= "function" then return end
local timer = createTimer(nil, false)
timer.Interval = delay
if type(iterations) == "number" and iterations > 0 then
timer.OnTimer = function(timer)
listener(timer, iterations)
iterations = iterations - 1
if iterations <= 0 then
timer.Enabled = false
timer.Destroy()
end
end
else
timer.OnTimer = listener
end
timer.Enabled = true
return timer
end
local timer1 = performWithDelay(1000, doThis, 10)
sleep(500)
local timer2 = performWithDelay(1000, doThat, 10) |
|
|
Back to top |
|
|
akumakuja28 Master Cheater Reputation: 16
Joined: 28 Jun 2015 Posts: 432
|
Posted: Sat Dec 31, 2016 5:20 am Post subject: |
|
|
Zanzer thts pretty slick.
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sat Dec 31, 2016 5:59 am Post subject: |
|
|
Thanks Zanzer sir,
Your script looking great. I have made a speed hack tool. I made speed hack tool with accepting timer in seconds and speed hack value input by user. Then after elapse timer given by user, it will return to normal speed hack = 1. This speed hack tool work properly.
Now, I want to modify that speed hack tool by adding a label which will displaying countdown timer according to timer given by user.
I don't know how to apply your script above into my script.
I try without your script also, but not work properly yet.
Code: | ----APPLY SPEED AND COUNTDOWN TIMER
function Btn_GoClick(sender)
tmr = tonumber(control_getCaption(UDF1.Edit_Timer))
spvl = tonumber(control_getCaption(UDF1.Edit_Speed))
-- if tonumber(tmr) == nil or type(tmr) == 'string' or tonumber(spv1) == nil or type(spv1) == 'string' then
-- showMessage('Input timer is not number')
-- end
-- THIS PART ALSO GET MESSAGE spv1 is not a number -- How ???
t1.Interval=tmr
speedhack_setSpeed(spvl)
secondsLeft = tmr/1000 * 60
t1.OnTimer=function(t1)
secondsLeft = secondsLeft - 1
minutes = math.floor( secondsLeft / 60 )
seconds = secondsLeft % 60
if minutes == 0 and seconds == 0 then t.Enabled=false end
timeDisplay = string.format( "%02d:%02d", minutes, seconds )
control_setCaption(UDF1.Lbl_SpDisp,tostring(spvl).." x")
control_setCaption(UDF1.Lbl_CtDown, tostring(timeDisplay))
end
t1.Enabled=true
end
function resetSpeed()
if (t1) then
t1.Enabled=false
end
speedhack_setSpeed(1)
control_setCaption(UDF1.Edit_Timer,"0000")
control_setCaption(UDF1.Edit_Speed,"0.0")
control_setCaption(UDF1.Lbl_SpDisp,"0.0 x")
control_setCaption(UDF1.Lbl_CtDown, "00:00")
end
t1=createTimer(nil, false)
t1.onTimer=resetSpeed
function Btn_ResetClick(sender)
if t1 and t1.Destroy then t1.Destroy() end
speedhack_setSpeed(1)
control_setCaption(UDF1.Edit_Timer,"0000")
control_setCaption(UDF1.Edit_Speed,"0.0")
control_setCaption(UDF1.Lbl_SpDisp,"0.0 x")
control_setCaption(UDF1.Lbl_CtDown, "00:00")
end |
I would be very glad if you deign can help improve my script.
Thanks and regards
Description: |
|
Filesize: |
32.03 KB |
Viewed: |
17393 Time(s) |
|
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Dec 31, 2016 9:07 am Post subject: |
|
|
Edit boxes use the .Text property, not .Caption Code: | tmr = tonumber(UDF1.Edit_Timer.Text)
spvl = tonumber(UDF1.Edit_Speed.Text) |
My number to time string function is much more compact. Code: | local timeDisplay = os.date("!%M:%S", secondsLeft) |
This only needs to run once, so keep it outside of the timer. Code: | UDF1.Lbl_SpDisp.Caption = string.format("%0.1f x", spvl) |
I would change your disable condition to: Code: | if secondsLeft <= 0 then
t.Enabled=false
t.Destroy()
end |
Also, since you're destroying the timer, you need to create it again inside Btn_GoClick.
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Dec 31, 2016 12:48 pm Post subject: |
|
|
Code: | --############ do not change this one #######################
function performWithDelay(delay,onFinish,onTick,onTickInterval)
if type(delay)~='number' -- mandatory
then error('delay is not a number') end
if type(onFinish)~='function' -- mandatory
then error('onFinish is not a function') end
if onTick and type(onTick)~='function' -- optional
then error('onTick is not a function') end
if onTickInterval and type(onTickInterval)~='number' -- optional, default 1 second
then error('onTickInterval is not a number') end
onTickInterval = onTickInterval or 1000 -- default 1 second
local f = function (t) -- thread function start
local getTickCount = getTickCount
local startTick = getTickCount()
local endTick = startTick + delay
local nextOnTick = startTick + onTickInterval
local ticks
if onTick then
while true do
ticks=getTickCount()
if nextOnTick<ticks then
nextOnTick=ticks+onTickInterval
synchronize(onTick,endTick-ticks)
end
if endTick<ticks then break end
sleep(1)
end
else
while true do
ticks=getTickCount()
if endTick<ticks then break end
sleep(1)
end
end
if onFinish then synchronize(onFinish) end
end -- thread function end
local t = createNativeThreadSuspended(f)
t.name = 'performWithDelay thread'
t.resume()
end
--###########################################################
function showTimeLeft(millisecondsLeft)
local totalSeconds = millisecondsLeft // 1000
local deciseconds = (millisecondsLeft % 1000) // 100
UDF1.CELabel1.Caption = os.date("!%M:%S",totalSeconds)..'.'..deciseconds
end
function whenFinished()
UDF1.CELabel1.Caption = "00:00.0"
UDF1.CELabel1.Font.Color = 0x000000 -- black
speedhack_setSpeed(1)
UDF1.CEButton1.Enabled = true
end
function startSpeedHack()
UDF1.CELabel1.Font.Color = 0x005500 -- green
speedhack_setSpeed(0.5)
--performWithDelay(delayInMilliseconds,onFinish,onTick,onTickIntervalInMilliseconds)
performWithDelay(12500,whenFinished,showTimeLeft,10)
UDF1.CEButton1.Enabled = false
end
UDF1.show()
UDF1.CEButton1.OnClick = startSpeedHack |
example table below
Description: |
|
Download |
Filename: |
performWithDelay.CT |
Filesize: |
2.73 KB |
Downloaded: |
987 Time(s) |
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sat Dec 31, 2016 7:51 pm Post subject: |
|
|
Finally
Code: | function Btn_GoClick(sender)
tmr = tonumber(UDF1.Edit_Timer.Text)
spvl = tonumber(UDF1.Edit_Speed.Text)
-- if tonumber(tmr) == nil or type(tmr) == 'string' or tonumber(spv1) == nil or type(spv1) == 'string' then
-- showMessage('Input timer is not number')
-- end
t1=createTimer(nil, false)
t1.Interval=tmr
speedhack_setSpeed(spvl)
secondsLeft = tmr/1000 * 60
t1.OnTimer=function(t1)
secondsLeft = secondsLeft - 1
minutes = math.floor( secondsLeft / 60 )
seconds = secondsLeft % 60
-- if minutes == 0 and seconds == 0 then t.Enabled=false end
if secondsLeft <= 0 then resetSpeed();t1.Enabled=false; t1.Destroy(); end
-- timeDisplay = string.format( "%02d:%02d", minutes, seconds )
local timeDisplay = os.date("!%M:%S", secondsLeft)
UDF1.Lbl_SpDisp.Caption = string.format("%0.1f x", spvl)
UDF1.Lbl_CtDown.Caption = tostring(timeDisplay)
-- control_setCaption(UDF1.Lbl_SpDisp,tostring(spvl).." x")
-- control_setCaption(UDF1.Lbl_CtDown, tostring(timeDisplay))
end
t1.Enabled=true
end
function resetSpeed()
if (t1) then
t1.Enabled=false
end
speedhack_setSpeed(1)
end
t1=createTimer(nil, false)
t1.onTimer=resetSpeed()
function Btn_ResetClick(sender)
if t1 and t1.Destroy then t1.Destroy() end
speedhack_setSpeed(1)
control_setCaption(UDF1.Edit_Timer,"0000")
control_setCaption(UDF1.Edit_Speed,"0.0")
control_setCaption(UDF1.Lbl_SpDisp,"0.0 x")
control_setCaption(UDF1.Lbl_CtDown, "00:00")
end |
Just need providing math calculation for timer input. Because timer input field provided for value in seconds, then when input timer "2000" mean to get 2 seconds, but in script it will translate to 2 hours.
Now, I trying to fix it. Thank so much Zanzer sir.
Also thanks to mgr.inz.Player for the function. I am also will try to apply the function to my script.
Regards
EDIT :
mgr.inz.Player and Zanzer, I have tried :
Code: | --#############do not change this one #######################
function performWithDelay(delay,onFinish,onTick,onTickInterval)
if type(delay)~='number' -- mandatory
then error('delay is not a number') end
if type(onFinish)~='function' -- mandatory
then error('onFinish is not a function') end
if onTick and type(onTick)~='function' -- optional
then error('onTick is not a function') end
if onTickInterval and type(onTickInterval)~='number' -- optional, default 1 second
then error('onTickInterval is not a number') end
onTickInterval = onTickInterval or 1000 -- default 1 second
local f = function (t) -- thread function start
local getTickCount = getTickCount
local startTick = getTickCount()
local endTick = startTick + delay
local nextOnTick = startTick + onTickInterval
local ticks
if onTick then
while true do
ticks=getTickCount()
if nextOnTick<ticks then
nextOnTick=ticks+onTickInterval
synchronize(onTick,endTick-ticks)
end
if endTick<ticks then break end
sleep(1)
end
else
while true do
ticks=getTickCount()
if endTick<ticks then break end
sleep(1)
end
end
if onFinish then synchronize(onFinish) end
end -- thread function end
local t = createNativeThreadSuspended(f)
t.name = 'performWithDelay thread'
t.resume()
end
--- =============================================================================================== ---
UDF1.Edit_Timer.Text = "0000"
UDF1.Edit_Speed.Text = "0.0"
UDF1.Lbl_SpDisp.Caption = "0.0 x"
UDF1.Lbl_CtDown.Caption = "00:00.0"
function showTimeLeft(millisecondsLeft)
local totalSeconds = millisecondsLeft // 1000
local deciseconds = (millisecondsLeft % 1000) // 100
UDF1.Lbl_CtDown.Caption = os.date("!%M:%S",totalSeconds)..'.'..deciseconds
end
function whenFinished()
-- UDF1.CELabel1.Font.Color = 0x000000 -- black
speedhack_setSpeed(1)
beep()
sleep(5)
UDF1.Edit_Timer.Text = "0000"
UDF1.Edit_Speed.Text = "0.0"
UDF1.Lbl_SpDisp.Caption = "0.0 x"
UDF1.Lbl_CtDown.Caption = "00:00.0"
UDF1.Btn_Go.Enabled = true
end
function startSpeedHack()
tmr = tonumber(UDF1.Edit_Timer.Text)
spvl = tonumber(UDF1.Edit_Speed.Text)
UDF1.Lbl_CtDown.Font.Color = 0x005500 -- green
UDF1.Lbl_SpDisp.Caption = string.format("%0.1f x", spvl)
speedhack_setSpeed(spv1) ---- (0.5)
--performWithDelay(delayInMilliseconds,onFinish,onTick,onTickIntervalInMilliseconds)
performWithDelay(tmr,whenFinished,showTimeLeft,10) ---- (12500,whenFinished,showTimeLeft,10)
UDF1.Btn_Go.Enabled = false
end
function resetSpeed_n_Timer()
speedhack_setSpeed(1)
performWithDelay(0,whenFinished,showTimeLeft,0)
UDF1.Edit_Timer.Text = "0000"
UDF1.Edit_Speed.Text = "0.0"
UDF1.Lbl_SpDisp.Caption = "0.0 x"
UDF1.Lbl_CtDown.Caption = "00:00.0"
end
function closeTrainer()
closeCE();
return caFree
end
UDF1.show()
UDF1.Btn_Go.OnClick = startSpeedHack
UDF1.Btn_Reset.OnClick = resetSpeed_n_Timer
UDF1.Btn_Exit.OnClick = closeTrainer |
Results :
1. Set speedhack and timer according to user input work properly
Facing new problem :
1. When click RESET BUTTON, all classes value return to default value given except "performWithDelay(delayInMilliseconds,onFinish,onTick,onTickIntervalInMilliseconds)", it still continuing "countdown", how to make it stop suddenly by clicking Reset Button ?.
2. Open Attach a process by Open Attach Click Button
Code: | function pidDialog(doPid)
local plugname = {"iexplore","flashplayerplugin","plugin-container","opera","chrome","awesomium_process","torch","dragon","maxthon","palemoon","safari" }
local function tmerge(t,o,...) for k,v in pairs(o) do t[k]=v end if select('#',...)>0 then return tmerge(t,...) else return t end end
local function callLater(f,...)
local t = createTimer()
local a,n = {...},select('#',...)
t.Interval = 100
t.OnTimer = function(sender) sender.Enabled=false sender.Destroy() f(unpack(a,1,n)) end
t.Enabled = true
return t
end
local function parseProc(s)
local p,n
for pid,name in string.gmatch(s,'([0-9A-F]+)-(.*)') do
p = pid ; n = name
end
return p,n
end
local function prec(i,p,n)
local weight = 0
for _,v in ipairs(plugname) do
if string.find(string.lower(n),string.lower(v),1,true) then weight = weight + 1 end
end
return {pid=p,desc=string.format('%5d-%04X-%s',p,p,n),name=n,w=weight+i/2048}
end
local FP = createForm(false)
tmerge(FP,{FormStyle='fsStayOnTop',AutoSize=true,BorderWidth=4,Color=0x6495ED,Position='poScreenCenter',BorderStyle='bsToolWindow',Caption='Double Click to Select'})
local LB = createListBox(FP)
tmerge(LB,{MultiSelect=false,AutoSize=true,Color=0x6495ED})
local cs = LB.Constraints
tmerge(cs,{MinHeight=300,MinWidth=400})
local fn = LB.Font
tmerge(fn,{Color=0xffffff,Name='Courier New',Height=-16,Style='[bsBold]'})
LB.OnDblClick = function()
local idx,PID,NAME = LB.ItemIndex,nil,''
if idx >= 0 then
for pid,pID,name in string.gmatch(LB.Items[idx],'([0-9]+)-\\s*([0-9A-F]+)-(.*)') do
PID = tonumber(pid,10)
NAME = name
end
end
if PID ~= nil then callLater(doPid,PID,NAME) end
FP.close()
end
FP.OnClose = function() FP.destroy(); FP = nil end
getProcesslist(LB.Items)
local plist = {}
for i=1,LB.Items.getCount() do
local p,n = parseProc(LB.Items[i-1])
p = tonumber(p,16)
table.insert(plist,prec(i,p,n))
end
table.sort(plist,function(a,b) return a.w > b.w end)
local currProcId = getOpenedProcessID()
for i=1,LB.Items.getCount() do
LB.Items.setString(i-1,plist[i].desc)
if plist[i].pid == currProcId then LB.setItemIndex(i-1) end
end
FP.show()
end
function Btn_AttachClick(sender)
pidDialog(function(pid,name)
OpenProcess(pid)
UDF1.Lbl_Attach.Caption = string.format('%4X-%s',pid,name)
control_setEnabled(UDF1.Btn_Go, true)
control_setEnabled(UDF1.Btn_Reset, true)
end)
end |
That script work fine while using CE 6.4, but when using CE 6.6 it's give an error "error to call nil value", sound like CE can't recognized a class name or variable name. I can't debug it to find where or what thing has given error.
But, when the trainer save as a stand alone EXE trainer, it work (about attach process), except Buttons "Go" and "Reset" not going to "Enable, true" (by default it's set enabled, false) to prevent user doing anything before they select a process attach first.
Would you help to fix the problems ?
Thank you
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Jan 01, 2017 9:01 am Post subject: |
|
|
few adjustments:
Code: | local function callLater(f,...)
local a = {...}
local t = createTimer(nil,false)
t.Interval = 100
t.OnTimer = function(sender) sender.Enabled=false sender.Destroy() f(unpack(a)) end
t.Enabled = true
return t
end |
Code: | local function parseProc(s)
return string.match(s,'(.-)%-(.*)')
end |
Code: | LB.OnDblClick = function()
local idx,PID,NAME = LB.ItemIndex,nil,''
if idx >= 0 then
PID,NAME = string.match(LB.Items[idx],'(.-)%-.*%-(.*)')
PID = tonumber(PID,10)
callLater(doPid,PID,NAME)
FP.close()
end
end |
Speed hack thing:
Code: | --############ do not change this one #######################
function performWithDelay(delay,onFinish,onTick,onTickInterval)
if type(delay)~='number' -- mandatory
then error('delay is not a number') end
if type(onFinish)~='function' -- mandatory
then error('onFinish is not a function') end
if onTick and type(onTick)~='function' -- optional
then error('onTick is not a function') end
if onTickInterval and type(onTickInterval)~='number' -- optional, default 1 second
then error('onTickInterval is not a number') end
onTickInterval = onTickInterval or 1000 -- default 1 second
local f = function (t) -- thread function start
local getTickCount = getTickCount
local startTick = getTickCount()
local endTick = startTick + delay
local nextOnTick = startTick + onTickInterval
local ticks
if onTick then
while not t.Terminated do
ticks=getTickCount()
if nextOnTick<ticks then
nextOnTick=ticks+onTickInterval
synchronize(onTick,endTick-ticks)
end
if endTick<ticks then break end
sleep(1)
end
else
while not t.Terminated do
ticks=getTickCount()
if endTick<ticks then break end
sleep(1)
end
end
if onFinish then synchronize(onFinish) end
end -- thread function end
local t = createNativeThreadSuspended(f)
t.name = 'performWithDelay thread'
t.resume()
return t
end
--- =============================================================================================== ---
UDF1.Edit_Timer.Text = "0000"
UDF1.Edit_Speed.Text = "0.0"
UDF1.Lbl_SpDisp.Caption = "0.0 x"
UDF1.Lbl_CtDown.Caption = "00:00.0"
function showTimeLeft(millisecondsLeft)
local totalSeconds = millisecondsLeft // 1000
local deciseconds = (millisecondsLeft % 1000) // 100
UDF1.Lbl_CtDown.Caption = os.date("!%M:%S",totalSeconds)..'.'..deciseconds
end
function whenFinished()
mythread1=nil
-- UDF1.CELabel1.Font.Color = 0x000000 -- black
speedhack_setSpeed(1)
beep()
sleep(5)
UDF1.Edit_Timer.Text = "0000"
UDF1.Edit_Speed.Text = "0.0"
UDF1.Lbl_SpDisp.Caption = "0.0 x"
UDF1.Lbl_CtDown.Caption = "00:00.0"
UDF1.Btn_Go.Enabled = true
end
function startSpeedHack()
tmr = tonumber(UDF1.Edit_Timer.Text)
spvl = tonumber(UDF1.Edit_Speed.Text)
UDF1.Lbl_CtDown.Font.Color = 0x005500 -- green
UDF1.Lbl_SpDisp.Caption = string.format("%0.1f x", spvl)
speedhack_setSpeed(spv1) ---- (0.5)
--performWithDelay(delayInMilliseconds,onFinish,onTick,onTickIntervalInMilliseconds)
mythread1 = performWithDelay(tmr,whenFinished,showTimeLeft,10) ---- (12500,whenFinished,showTimeLeft,10)
UDF1.Btn_Go.Enabled = false
end
function resetSpeed_n_Timer()
if mythread1 then mythread1.terminate() end
mythread1=nil
end
function closeTrainer()
closeCE();
return caFree
end
UDF1.show()
UDF1.Btn_Go.OnClick = startSpeedHack
UDF1.Btn_Reset.OnClick = resetSpeed_n_Timer
UDF1.Btn_Exit.OnClick = closeTrainer |
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sun Jan 01, 2017 8:55 pm Post subject: |
|
|
Finally all done. Everything tested and work properly.
Thank so much mgr.inz.Player and Zanzer.
CT file as attached.
Regards
Description: |
|
Filesize: |
24.97 KB |
Viewed: |
17013 Time(s) |
|
Description: |
Speedhack tool with countdown timer |
|
Download |
Filename: |
CRDR - Speed Hack Timer Ver.1.1.CT |
Filesize: |
46.16 KB |
Downloaded: |
1026 Time(s) |
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Mon Jan 02, 2017 9:37 am Post subject: |
|
|
resetSpeed_n_Timer function should only call mythread1.terminate() and set mythread1 to nil.
At the beginning of function whenFinished, you must set mythread1 to nil.
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Mon Jan 02, 2017 7:17 pm Post subject: |
|
|
Done, thank mgr.inz.Player.
Code: | function whenFinished()
-- UDF1.CELabel1.Font.Color = 0x000000 -- black
mythread1=nil
speedhack_setSpeed(1)
beep()
sleep(5)
UDF1.Edit_Timer.Text = "0000"
UDF1.Edit_Speed.Text = "0.0"
UDF1.Lbl_SpDisp.Caption = "0.0 x"
UDF1.Lbl_CtDown.Caption = "00:00.0"
UDF1.Btn_Go.Enabled = true
end |
Regards
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Wed Jan 04, 2017 7:07 pm Post subject: |
|
|
Fixed
Description: |
|
Download |
Filename: |
CRDR - Speed Hack Timer Fix Ver.1.1.CT |
Filesize: |
46.19 KB |
Downloaded: |
1021 Time(s) |
|
|
Back to top |
|
|
icsmoke+ Cheater Reputation: 0
Joined: 31 Aug 2020 Posts: 32
|
Posted: Thu Dec 16, 2021 10:32 pm Post subject: |
|
|
Code: |
--############ do not change this one #######################
function performWithDelay(delay,onFinish,onTick,onTickInterval)
if type(delay)~='number' -- mandatory
then error('delay is not a number') end
if type(onFinish)~='function' -- mandatory
then error('onFinish is not a function') end
if onTick and type(onTick)~='function' -- optional
then error('onTick is not a function') end
if onTickInterval and type(onTickInterval)~='number' -- optional, default 1 second
then error('onTickInterval is not a number') end
onTickInterval = onTickInterval or 1000 -- default 1 second
local f = function (t) -- thread function start
local getTickCount = getTickCount
local startTick = getTickCount()
local endTick = startTick + delay
local nextOnTick = startTick + onTickInterval
local ticks
if onTick then
while true do
ticks=getTickCount()
if nextOnTick<ticks then
nextOnTick=ticks+onTickInterval
synchronize(onTick,endTick-ticks)
end
if endTick<ticks then break end
sleep(1)
end
else
while true do
ticks=getTickCount()
if endTick<ticks then break end
sleep(1)
end
end
if onFinish then synchronize(onFinish) end
end -- thread function end
local t = createNativeThreadSuspended(f)
t.name = 'performWithDelay thread'
t.resume()
end
--###########################################################
function showTimeLeft(millisecondsLeft)
local totalSeconds = millisecondsLeft // 1000
local deciseconds = (millisecondsLeft % 1000) // 100
UDF1.CELabel1.Caption = os.date("!%M:%S",totalSeconds)..'.'..deciseconds
end
function whenFinished()
UDF1.CELabel1.Caption = "00:00.0"
UDF1.CELabel1.Font.Color = 0x000000 -- black
speedhack_setSpeed(1)
UDF1.CEButton1.Enabled = true
end
function startSpeedHack()
UDF1.CELabel1.Font.Color = 0x005500 -- green
speedhack_setSpeed(0.5)
--performWithDelay(delayInMilliseconds,onFinish,onTick,onTickIntervalInMilliseconds)
performWithDelay(12500,whenFinished,showTimeLeft,10)
UDF1.CEButton1.Enabled = false
end
UDF1.show()
UDF1.CEButton1.OnClick = startSpeedHack |
hello there, how to use this script in multiple times i mean not only once?
|
|
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
|
|