2

As the title says I'm trying to figure out how to get this piece of stolen code to work :p

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(5) -- to prevent it from being stuck on
  end
  if (event == "MOUSE_BUTTON_PRESSED" and arg == 3) then
    recoil = not recoil
    spot = not spot
  end

  if (event == "MOUSE_BUTTON_PRESSED" and arg == 5 and recoil) then
    if recoil then
      repeat
        Sleep(1)
        MoveMouseRelative(-400, 0)
        Sleep(1)
      until not IsMouseButtonPressed(5)
    end
  end
end

No matter what sleep timer I add I can't get it to work the way I want : I want a single press pixel perfect 180/360 degree turn in call of duty and not have to hold down the mb5 button in order to turn.

x5657
  • 1,172
  • 2
  • 13
  • 26
HENK pipo
  • 21
  • 1
  • 2

3 Answers3

1
  
MoveAmount = -400
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(4) -- to prevent it from being stuck on
  end
  
  

  if (event == "MOUSE_BUTTON_PRESSED" and arg == 4) then
    for x=1,10,1
    do
        MoveMouseRelative(MoveAmount, 0)
        Sleep(5)
       
    end
      
      
    
  end
end
MadJam
  • 11
  • 2
  • This works on desktop ... setting value to high seems to crash it so just moved a small amount multiple time. Will move once per mouse click so if you hold key down it wont repeat. – MadJam Sep 01 '20 at 06:59
0

While you're holding down mb5, then every 2 seconds, this line of code is happening:

MoveMouseRelative(-400, 0)

I guess the problem is that moving the mouse -400 pixels isn't exactly a 180 degree turn, and the correct number will probably be different for everyone depending on their mouse sensitivity settings.

You could try some different numbers instead of -400 to see if it works more like what you want.

x5657
  • 1,172
  • 2
  • 13
  • 26
0
function OnEvent(event, arg)
   OutputLogMessage("event = %s, arg = %d\n", event, arg)
   if (event == "PROFILE_ACTIVATED") then
      EnablePrimaryMouseButtonEvents(true)
   end
   if (event == "MOUSE_BUTTON_PRESSED" and arg == 3) then
      recoil = not recoil
      spot = not spot
   end
   if (event == "MOUSE_BUTTON_PRESSED" and arg == 5 and recoil) then
      local distance = 400  -- adjust this value
      while distance > 0 do
         local delta = math.min(100, distance)
         distance = distance - delta
         MoveMouseRelative(-delta, 0)
         Sleep(15)
      end
   end
end
Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64