[RESOLVED] lua speedhack toggle

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
isuckatall
What is cheating?
What is cheating?
Posts: 2
Joined: Sat Oct 15, 2022 5:23 pm
Reputation: 0

[RESOLVED] lua speedhack toggle

Post by isuckatall »

idk lua im trying to make speedhack toggleable with the e key and made this but it fail

if (isKeyPressed(VK_E)) then cycle()
end
function cycle()
if toggle ~= 0 then speedhack_setSpeed(0.25)
toggle = 1
else speedhack_setSpeed(1)
toggle = 0
end
end

Edit: im requesting someone to fix it so it operates as I intend
Last edited by isuckatall on Tue Oct 18, 2022 6:40 am, edited 2 times in total.

Cas
Expert Cheater
Expert Cheater
Posts: 263
Joined: Fri Mar 03, 2017 12:04 am
Reputation: 125

Re: lua speedhack toggle

Post by Cas »

Please don’t use clickbaity titles. I have edited it out.

isuckatall
What is cheating?
What is cheating?
Posts: 2
Joined: Sat Oct 15, 2022 5:23 pm
Reputation: 0

Re: lua speedhack toggle

Post by isuckatall »

ok sorry Casanova

User avatar
LeFiXER
LeFixer
LeFixer
Posts: 479
Joined: Wed Mar 24, 2021 9:35 am
Reputation: 242

Re: lua speedhack toggle

Post by LeFiXER »

This will work as intended:

Code: Select all

if tmr then tmr.destroy(); tmr = nil end

function ToggleSpeedHack(key, speed)
  if key == nil then key = 0x1B end             -- Escape key is default if not defined

  function setSpeed(speed)
     if speed == nil then speed = 1 end
     speedhack_setSpeed(speed)
  end

  tmr = createTimer(getMainForm())
  tmr.Interval = 20
  tmr.OnTimer = function()
                  if isKeyPressed(key) then
                     setSpeed(speed)
                  else
                     setSpeed(1)
                  end
                end
end

-- 0x45 = VK_E
ToggleSpeedHack(0x45, 3)
More VK_Key codes available [Link]

Post Reply

Who is online

Users browsing this forum: No registered users