Logitech Lua combining Rapid Fire with spray

让人想犯罪 __ 提交于 2020-08-10 22:02:17

问题


So basically, this is what my script looks like at the moment, it’s a rapid fire macro and reduces the recoil of the guns, however I can never spray with this script for some reason as it’s very slow because I guess it’s reducing the recoil. I was wondering if I could shoot like 4, 5 bullets without any recoil (only auto shoot while holding mouse 3 not while tapping.) and continue with spray like normal spray without any delays while already holding mouse3. So 4 bullets no recoil and rest the regular spray on the same cycle. If that makes any sense. Any help would be greatly appreciated.

EnablePrimaryMouseButtonEvents(true);

function OnEvent(event, arg) 
    if IsKeyLockOn("scrolllock")then
        if IsMouseButtonPressed(3) then
            repeat  
                if IsMouseButtonPressed(3) then
                    repeat
                        PressMouseButton(1)
                        Sleep(15)
                        ReleaseMouseButton(1)
                    until not IsMouseButtonPressed(3)
                end             
            until not IsMouseButtonPressed(3)
        end   
    end
end


回答1:


local rapid_fire_delay = 15   -- delay between simulation of LMB press/release
local LMB_Pressed
do  -- initializing PRNG
   local dt = 0
   for c in GetDate():gmatch"." do
      dt = (dt % 65537 * 23456 + c:byte())
   end
   math.randomseed(dt)
end

function OnEvent(event, arg)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 2 and IsKeyLockOn("scrolllock") then   -- RMB press
      for j = 1, math.random(4, 5) do  -- first 4-5 bullets as rapid-fire
         PressMouseButton(1)
         Sleep(math.random(rapid_fire_delay, 2*rapid_fire_delay))
         ReleaseMouseButton(1)
         Sleep(math.random(rapid_fire_delay, 2*rapid_fire_delay))
         if not IsMouseButtonPressed(3) then return end  -- is RMB pressed?
      end
      PressMouseButton(1)
      LMB_Pressed = true
   elseif event == "MOUSE_BUTTON_RELEASED" and arg == 2 and LMB_Pressed then   -- RMB release
      ReleaseMouseButton(1)
      LMB_Pressed = false
   elseif event == "MOUSE_BUTTON_PRESSED" and arg == 5 then 
      repeat 
         Sleep(15) 
         PressKey("SPACEBAR") 
         Sleep(15) 
         ReleaseKey("SPACEBAR") 
      until not IsMouseButtonPressed(5) 
   end 
end

The line for j = 1, math.random(4, 5) do means "a random quantity from 4 to 5 bullets".
If you want exactly 3 bullets change this line to for j = 1, 3 do



来源:https://stackoverflow.com/questions/62541412/logitech-lua-combining-rapid-fire-with-spray

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!