Posted: Mon Dec 19, 2016 12:25 am Post subject: 2 Speed hacks 2 binds one code.
So I have this CE code that I was trying to make work together. I have a code that works but it wants to keep resetting it to 1 when I'm holding down one of them. So I was wondering how would I fix it so it wouldn't spam 1 as I tried to use one of the speed binds.
Code:
astSpeed=1;
function checkKeys(timer)
if (isKeyPressed(VK_V)) then if lastspeed ~= 10 then speedhack_setSpeed(10) lastSpeed=10 end
else if lastspeed ~= 1 then speedhack_setSpeed(1) lastSpeed=1 end
function checkKeys(timer)
if (isKeyPressed(VK_C)) then if lastspeed ~= 0.1 then speedhack_setSpeed(0.1) lastSpeed=0.1 end
else if lastspeed ~= 1 then speedhack_setSpeed(1) lastSpeed=1 end
end
Just so you're aware, this is what your code would look like if it were properly indented and spaced:
Code:
astSpeed=1;
function checkKeys(timer)
if (isKeyPressed(VK_V)) then
if lastspeed ~= 10 then
speedhack_setSpeed(10)
lastSpeed = 10
end
else
if lastspeed ~= 1 then
speedhack_setSpeed(1)
lastSpeed = 1
end
function checkKeys(timer)
if (isKeyPressed(VK_C)) then
if lastspeed ~= 0.1 then
speedhack_setSpeed(0.1)
lastSpeed = 0.1
end
else
if lastspeed ~= 1 then
speedhack_setSpeed(1)
lastSpeed = 1
end
end
end
end
Okay so yes that helped organize it a lot but I got it working to an extent. Now when I hold c the slowmo works fine. But when I hold V it tries to create a timer switching the 1 to 10 and back repeatidly so if you know how to fix this It would be an amazing help.
Code:
astSpeed=1;
function checkKeys(hotkey)
if (isKeyPressed(VK_V)) then
if lastspeed ~= 10 then
speedhack_setSpeed(10)
lastSpeed = 10
end
else
if lastspeed ~= 1 then
speedhack_setSpeed(1)
lastSpeed = 1
end
if (isKeyPressed(VK_C)) then
if lastspeed ~= 0.1 then
speedhack_setSpeed(0.1)
lastSpeed = 0.1
end
else
if lastspeed ~= 1 then
speedhack_setSpeed(1)
lastSpeed = 1
end
end
end
end
if speedhack_fast then
speedhack_fast.Destroy()
end
speedhack_fast = createHotkey(function()
local speed = speedhack_getSpeed()
if speed ~= 1.0 then
speedhack_setSpeed(1.0)
else
speedhack_setSpeed(2.0)
end
end, VK_V)
if speedhack_slow then
speedhack_slow.Destroy()
end
speedhack_slow = createHotkey(function()
local speed = speedhack_getSpeed()
if speed ~= 1.0 then
speedhack_setSpeed(1.0)
else
speedhack_setSpeed(0.1)
end
end, VK_C)
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