View previous topic :: View next topic |
Author |
Message |
pgkw2 How do I cheat? Reputation: 0
Joined: 15 Aug 2019 Posts: 2
|
Posted: Thu Aug 15, 2019 12:20 pm Post subject: I think this is so simple yet I'm struggling with it >< |
|
|
Hello guys,
I'm struggling to get this done:
when R is pressed(not held down, just a key stroke) set speed to 0.5 for 7 seconds then reset it to 1 when 7 seconds pass, but if during the 7 seconds R is pressed again then set speed to 1 instantly before the 7 seconds pass.
any idea how to do that?
my current script does what I'm asking for except the last part, I tried different stuff but couldn't disable the sleep command ,here's my script:
function checkRKey(timer)
if (isKeyPressed(VK_R)) then
speedhack_setSpeed(0.5)
sleep(7000)
speedhack_setSpeed(1)
end
end
t=createTimer(nil)
timer_setInterval(t, 100)
timer_onTimer(t, checkRKey)
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Thu Aug 15, 2019 1:14 pm Post subject: |
|
|
Code: |
if hktmr then hktmr.destroy() hktmr=nil end
if hk then hk.destroy() hk=nil end
hktmr = createTimer()
hktmr.Interval = 5000
hktmr.Enabled = false
hktmr.OnTimer = function(t)
local s = speedhack_getSpeed()
s = s == 1 and 0.5 or 1 -- flip
speedhack_setSpeed(s)
t.Enabled = false
end
hk = createHotkey(function()
local shouldenable = not hktmr.Enabled
hktmr.OnTimer(hktmr) -- change speed immediately and stops timer
hktmr.Enabled = shouldenable -- change back in 7 seconds or disable
end, VK_R) | I believe this should work. The first time it's run it'll call the timer's function which will change the speed to 0.5 and start the timer which will change it back to 1 after 7 seconds and stop the timer, if you press it when it's already enabled it will immediately change the speed (to 1) and then disable the timer.
_________________
|
|
Back to top |
|
|
pgkw2 How do I cheat? Reputation: 0
Joined: 15 Aug 2019 Posts: 2
|
Posted: Thu Aug 15, 2019 4:27 pm Post subject: |
|
|
FreeER wrote: | Code: |
if hktmr then hktmr.destroy() hktmr=nil end
if hk then hk.destroy() hk=nil end
hktmr = createTimer()
hktmr.Interval = 5000
hktmr.Enabled = false
hktmr.OnTimer = function(t)
local s = speedhack_getSpeed()
s = s == 1 and 0.5 or 1 -- flip
speedhack_setSpeed(s)
t.Enabled = false
end
hk = createHotkey(function()
local shouldenable = not hktmr.Enabled
hktmr.OnTimer(hktmr) -- change speed immediately and stops timer
hktmr.Enabled = shouldenable -- change back in 7 seconds or disable
end, VK_R) | I believe this should work. The first time it's run it'll call the timer's function which will change the speed to 0.5 and start the timer which will change it back to 1 after 7 seconds and stop the timer, if you press it when it's already enabled it will immediately change the speed (to 1) and then disable the timer. |
Thank you , just what I was asking for
|
|
Back to top |
|
|
|