问题:为了实现左右键同时按下才会压枪,我就做了这个宏,但是经常失效,有时候左右同时按下无反应,有时候又正常,是在莫名其妙!
KG=3--开关键位
ZuoJian=1--左键键位
YouJian=2--右键键位
gun=0--灯光状态阀
KGzt=false--初始开关状态
Zzt=false--左键状态
Yzt=false--右键状态
OnClick=false
-------------------------------压枪参数------ Di_n 不能为0 否则第三发之后所有子弹都不会下压-------------------------------------
akm_speed = 0.01 --增量
AKM_SheJiJianGe = 65 --射击间隔
AKM_PingHua = 5 --平滑参数
--UPM9设置1
AKM_Di_n = 10 --压枪子弹参数
------------------------------其他参数--------------------------------------------
AKM_Speed = 0
AKM_ZiDan_CiShu = 0
function OnEvent(event, arg)
--OutputLogMessage("event = %s, arg = %s\n", event, arg);--允许反馈按键反馈
EnablePrimaryMouseButtonEvents(true);--解除鼠标按键1屏蔽
if(event == "MOUSE_BUTTON_PRESSED" and arg == KG)then
KGzt= not KGzt
if(KGzt)then
OutputLogMessage("On \n")
else
OutputLogMessage("Off \n")
end
if (gun==0)then
PressKey("scrolllock")
gun=1
end
if (gun ==1) then
gun=0
ReleaseKey("scrolllock")
end
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and KGzt) then
Zzt= not Zzt--修改左键状态
end
if (event == "MOUSE_BUTTON_RELEASED" and arg == 1 and KGzt) then
Zzt=false--放开恢复左键状态
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 2 and KGzt) then
Yzt= not Yzt--修改右键状态
end
if (event == "MOUSE_BUTTON_RELEASED" and arg == 2 and KGzt) then
Yzt=false--放开恢复右键状态
end
--------------------执行步骤-------------------------
if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and Yzt) then
OnClick = not OnClick
YAQIANG_AKM()
end
if (event == "MOUSE_BUTTON_RELEASED" and arg == 1) then
chushi()
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 2 and Zzt) then
OnClick = not OnClick
YAQIANG_AKM()
end
if (event == "MOUSE_BUTTON_RELEASED" and arg == 2) then
chushi()
end
---------------------------增量初始化-------------------------
function chushi()
AKM_Speed = 0
end
-------------------------弹道参数-----------------------------
function YAQIANG_AKM()
AKM_ZiDan_CiShu = 1
repeat
EnablePrimaryMouseButtonEvents(true);--解除鼠标按键1屏蔽
if(IsMouseButtonPressed(1))then--判断开火键是否按下
if(AKM_ZiDan_CiShu >= AKM_PingHua)then
MoveMouseRelative(0,AKM_Di_n/AKM_PingHua + AKM_Speed)
end
Sleep(AKM_SheJiJianGe/AKM_PingHua)
AKM_ZiDan_CiShu = AKM_ZiDan_CiShu + 1
AKM_Speed = AKM_Speed + akm_speed
else
break
end
until (not OnClick )
end
end
|