Reputation: 3
i'm trying to make a script for my mouse for a game . Basically this is what it has to do:
Here's the code i've been trying to write but can't figure out the 2 part of my request:
Thanks for the help :)
local zoomed = false
local weapons = true
EnablePrimaryMouseButtonEvents(true)
function OnEvent(event, arg)
if (event == "MOUSE_BUTTON_PRESSED" and arg == 2 and weapons) then
zoomed = true
end
if (event == "MOUSE_BUTTON_RELEASED" and arg == 2 and weapons) then
zoomed = false
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and zoomed) then
PressKey("q")
ReleaseKey("q")
end
if IsKeyLockOn("numlock")then
if (event == "MOUSE_BUTTON_PRESSED" and arg == 2) then
PressKey("f")
Sleep(5)
ReleaseKey("f")
end
end
end
Upvotes: 0
Views: 2011
Reputation: 23747
Set flag press_F_on_RMB_release
to know that F
should be pressed on the next right mouse button release event.
local RMB_pressed = false
local press_F_on_RMB_release = false
function OnEvent(event, arg)
if event == "PROFILE_ACTIVATED" then
EnablePrimaryMouseButtonEvents(true)
elseif event == "MOUSE_BUTTON_PRESSED" and arg == 2 then
RMB_pressed = true
elseif event == "MOUSE_BUTTON_RELEASED" and arg == 2 then
RMB_pressed = false
if press_F_on_RMB_release then
PressKey("f")
Sleep(30)
ReleaseKey("f")
press_F_on_RMB_release = false
end
elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 and RMB_pressed then
PressKey("q")
Sleep(30)
ReleaseKey("q")
if IsKeyLockOn("numlock") then
PressKey("f")
Sleep(30)
ReleaseKey("f")
press_F_on_RMB_release = true
end
end
end
Upvotes: 1