Reputation: 1
EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
if IsKeyLockOn("capslock") and IsMouseButtonPressed(1) and IsMouseButtonPressed(3) then
repeat
PressMouseButton(1)
Sleep(13)
ReleaseMouseButton(1)
Sleep(15)
PressMouseButton(1)
Sleep(18)
ReleaseMouseButton(1)
Sleep(12)
PressMouseButton(1)
Sleep(14)
ReleaseMouseButton(1)
Sleep(16)
until not IsMouseButtonPressed(3)
end
end
Upvotes: -1
Views: 99
Reputation: 1928
The problem is: you cannot both simulate a mouse button press/release and monitor the same mouse button state (pressed/released) simultaneously.
To solve the problem you may:
This answer describes how to implement the second option.
You need to satisfy all 3 steps:
In the game, in the "Controls Settings", introduce alternative key for "Shoot" action.
(I assume your game allows binding two different keys for the same action)
For example, let it be keyboard key P.
So, now in the game you can shoot either using Left Mouse Button or using Keyboard key P.
Of course, you will use LMB for manual shooting as usually, but your LGS/GHub script will use P.
Try to play the game with both LMB and P for shooting.
Make sure you can shoot with P key while keeping LMB pressed.
(Some games do not allow this)
The script
EnablePrimaryMouseButtonEvents(true)
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 1
and IsKeyLockOn("capslock") and IsMouseButtonPressed(3)
then
repeat
Sleep(math.random(10,30))
PressKey("P")
Sleep(math.random(10,30))
ReleaseKey("P")
until not (IsMouseButtonPressed(1) and IsMouseButtonPressed(3))
end
end
Upvotes: -1