0
votes

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
the code from this question seem very similar does the answer help you? stackoverflow.com/questions/58121181/…Nifim
No sir,I think what the other script does Is the rapid fire only activates when ctrl key is pressed. What I am trying to do is when I hold mouse2, it auto shoots 4,5 Bullets only while HOLDING not while tapping then regular spray after the rapid fire.Vatzepack
it’s a rapid fire macro and reduces the recoil of the guns - No. Your script is a pure rapid fire. It does not reduce recoil. Are you talking about some other script, not the one you have posted?Egor Skriptunoff
Yes it is a rapid fire script, but when you rifle with the rapid fire script, thé bursts are accurate as hell with 3,4 bullets going straight depending on what gun you are using, that’s why I call it a no recoil script even tho it’s a rapid fire script. What I need help with is forcing the script to rapid fire 4 bullets and then regular spray after the script is done shooting four bullets, basically this script with only 4 bullets and then regular spray....( Guess it is impossible with lua, but somehow I manage to get it working for Oscar macro, bloody mouse.)Vatzepack
So, you're pressing right mouse button to turn rapid fire on. And all you want now is just to simply release RMB after 4 bullets despite of you're still keeping RMB pressed physically?Egor Skriptunoff

1 Answers

0
votes
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


EDIT:

This is instruction on how to make the rapidfire turn on only after LMB double-click.
Usual slow LMB click will not trigger rapidfire.

local Prev_LMB_Time, LMB_Pressed = 0
function OnEvent(event, arg)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
      if IsKeyLockOn("scrolllock") then
         local tm = GetRunningTime()
         tm, Prev_LMB_Time = tm - Prev_LMB_Time, tm
         if tm < 200 then  -- LMB double-click
            for j = 1, 100 do
               PressMouseButton(1)
               Sleep(1)
               ReleaseMouseButton(1)
               Sleep(1)
               if not IsMouseButtonPressed(4) then return end
            end
         end
      end
      PressMouseButton(1)
      LMB_Pressed = true
   elseif event == "MOUSE_BUTTON_RELEASED" and arg == 1 and LMB_Pressed then
      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

Currently you have in GHUB:

Primary Click = G1
Back          = G4 G8

What you should do in GHUB (in this order):

  1. Bind "Primary Click" to G8 (from now on, use button#8 instead of LMB)
  2. Bind "Back" to G1
  3. Set the script
Now you should have the following:
Primary Click = G8
Back          = G1 G4

Mouse button#8 is now "spare LMB" just in case LMB works incorrectly.