-1

您好,我想结合这 2 个切换脚本。这是为了游戏。我不擅长这个脚本,我需要合并脚本的帮助。我想

  • 当我按下 G7 按钮时,当我按下
    鼠标左键时,鼠标下拉 x 像素
  • 当我按下 g8 按钮
    时,当我按下鼠标左键时,鼠标会下拉 y 像素。

脚本1

function OnEvent(event, arg)
  OutputLogMessage("event = %s, arg = %d\n", event, arg)
  if (event == "PROFILE_ACTIVATED") then
    EnablePrimaryMouseButtonEvents(true)
  elseif event == "PROFILE_DEACTIVATED" then
    ReleaseMouseButton(2) -- to prevent it from being stuck on
  end
  if (event == "MOUSE_BUTTON_PRESSED" and arg == 7) then
    recoil = not recoil
    spot = not spot
  end

  if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil) then
    if recoil then
      repeat

        Sleep(2)
        MoveMouseRelative(-1, 1)
        Sleep(2)
        MoveMouseRelative( 0.5 , 2)
        Sleep(2)
        MoveMouseRelative( 1, 30)
        Sleep(6)

      until not IsMouseButtonPressed(1)

    end
  end
end

脚本2

function OnEvent(event, arg)
  OutputLogMessage("event = %s, arg = %d\n", event, arg)
  if (event == "PROFILE_ACTIVATED") then
    EnablePrimaryMouseButtonEvents(true)
  elseif event == "PROFILE_DEACTIVATED" then
    ReleaseMouseButton(2) -- to prevent it from being stuck on
  end
  if (event == "MOUSE_BUTTON_PRESSED" and arg == 8) then
    recoil = not recoil
    spot = not spot
  end

  if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil) then
    if recoil then
      repeat

        Sleep(2)
        MoveMouseRelative(-1, 1)
        Sleep(2)
        MoveMouseRelative( 0.5 , 2)
        Sleep(2)
        MoveMouseRelative( 1, 10)
        Sleep(6)

      until not IsMouseButtonPressed(1)

    end
  end
end
4

2 回答 2

0
function OnEvent(event, arg)
   OutputLogMessage("event = %s, arg = %d\n", event, arg)
   if event == "PROFILE_ACTIVATED" then
      EnablePrimaryMouseButtonEvents(true)
   elseif event == "PROFILE_DEACTIVATED" then
      ReleaseMouseButton(2) -- to prevent it from being stuck on
   elseif event == "MOUSE_BUTTON_PRESSED" and (arg == 7 or arg == 8) then     
      recoil = recoil ~= arg and arg
   elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil == 7 then
      repeat
         Sleep(2)
         MoveMouseRelative(-1, 1)
         Sleep(2)
         MoveMouseRelative( 0.5 , 2)
         Sleep(2)
         MoveMouseRelative( 1, 30)
         Sleep(6)
      until not IsMouseButtonPressed(1)
   elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil == 8 then
      repeat
         Sleep(2)
         MoveMouseRelative(-1, 1)
         Sleep(2)
         MoveMouseRelative( 0.5 , 2)
         Sleep(2)
         MoveMouseRelative( 1, 10)
         Sleep(6)
      until not IsMouseButtonPressed(1)
   end
end
于 2020-11-20T19:29:21.923 回答
0

不完全确定您的目标是什么,但这听起来与您想要实现的目标相似。您可能需要添加一些MoveMouseRelative(x, y)坐标对以使其正确瞄准,但这应该接近您正在寻找的逻辑。

function OnEvent( event, arg )
    OutputLogMessage( 'event = %s, arg = %d\n',  event,  arg )

    if event == 'PROFILE_ACTIVATED' then
        EnablePrimaryMouseButtonEvents( true )

    elseif event == 'PROFILE_DEACTIVATED' then
        EnablePrimaryMouseButtonEvents( false )

    --~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    elseif event == 'MOUSE_BUTTON_PRESSED' and arg == 7 then
        spot = not spot  --  toggle horizontal X spot-drift by pressing button 7

    elseif event == 'MOUSE_BUTTON_PRESSED' and arg == 1 and spot then
        while IsMouseButtonPressed( 1 ) do
            MoveMouseRelative( -1, 0 )  --  left on the X axis, enable/disable with button 7
            Sleep( 2 )
        end

    --~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    elseif event == 'MOUSE_BUTTON_PRESSED' and arg == 8 then
        recoil = not recoil  --  toggle vertical Y recoil-compensation by pressing button 8

    elseif event == 'MOUSE_BUTTON_PRESSED' and arg == 1 and recoil then
        while IsMouseButtonPressed( 1 ) do
            MoveMouseRelative( 0, 1 )  --  down on the Y axis, enable/disable with button 8
            Sleep( 2 )
        end
    end
end
于 2020-11-20T19:33:32.740 回答