How to make code work together ? lua script

45 views Asked by At

How to make the code correctly, so that the recoil is canceled out, and the button is held down together with "q"?

EnablePrimaryMouseButtonEvents(true);

function OnEvent(event, arg)
    if IsKeyLockOn("Numlock") then
        if IsMouseButtonPressed(1) then
            if IsKeyLockOn ("capslock") then
                PressAndReleaseKey("Q")
                Sleep(10000)
                PressAndReleaseKey("Q")
            end
            repeat
                MoveMouseRelative(0,4)
                Sleep(50)
            until not IsMouseButtonPressed(1)
        end
        if IsMouseButtonPressed(3)then
            repeat
                if IsMouseButtonPressed(1) then
                    if IsKeyLockOn ("capslock") then
                        PressAndReleaseKey("Q")
                        Sleep(10000)
                        PressAndReleaseKey("Q")
                    end
                    repeat
                        MoveMouseRelative(0,4)
                        Sleep(1)
                    until not IsMouseButtonPressed(1)
                end
            until not IsMouseButtonPressed(3)
        end
    end
end

I'm a newbie, I made the code myself. As a result, first the button "Q" works by holding it down for 10 seconds and then releasing it, but I need it all together

if IsMouseButtonPressed(1) then
    if IsKeyLockOn ("capslock") then
        PressAndReleaseKey("Q")
        Sleep(10000)
        PressAndReleaseKey("Q")
    end
    repeat
        MoveMouseRelative(0,4)
        Sleep(50)
    until not IsMouseButtonPressed(1)
end
0

There are 0 answers