CF宏文件使用教程

CF宏文件使用教程

前言

Tips: 此篇文章代码全部开源,仅可用于娱乐和学习,不可将其作为商用,不可在正式服中使用,否则一切后果自行承担,请自重!!!

因为鼠标宏非常多,想着自己也有罗技鼠标,看能不能自己写一写让游玩的时候更方便操作一些,可能不一定有什么帮助,但也是一个学习的过程,下面就把我自己的心得和代码详细的记录下来,好多参数都是自己一遍遍试出来的,博主的鼠标是 G102、G502,有俩个侧键,Ghub 一定要以管理员身份运行才能使用功能,如果给你提供了灵感,咱们也可以相互提升

一、宏文件简介

因为罗技官方 Ghub 驱动的编写脚本所需语言就是 lua,我们只需要学习简单的基础即可,比如 if else 判断,while 循环,全局变量,注释方式之类就足够了。

我在这里把lua 语言与罗技Lua脚本API了解网站发出来(菜鸟教程是个不错的学习 Lua 基础的地方,这里仅为示例网站),大家可以去看看,当然也可以直接看下面的代码,代码里有注释,如果有什么问题也可以在评论区留言,我会尽量回复的

二、准备工作

拥有支持宏编程的鼠标:像罗技的 G102、G502 这类鼠标,它们可以借助 Ghub 驱动实现宏编程。

安装 Ghub 驱动:前往罗技官方网站,下载并安装适配你鼠标型号的 Ghub 驱动程序。安装完成后,以管理员身份运行 Ghub,不然部分功能可能无法使用。

学习基础 Lua 知识:通过前面给出的网站或者其他学习资源,掌握基本的 Lua 语法,像变量定义、条件判断、循环结构等。

三、宏文件写入或导入驱动

打开 Ghub 驱动:在电脑上找到 Ghub 图标右键管理身份运行打开并确保鼠标已正确连接到电脑。

进入宏编辑界面:在 Ghub 中找到你的鼠标设备,点击左上角图标进入游戏与应用程序界面选择桌面或者CF,然后点击配置文件选项卡下方的为选定应用程序添加配置文件。

新建宏:点击 “新建宏” 按钮,为宏命名并回车确定创建,名称例如 “CF_All_Lua”。

选定宏:找到 配置文件选项卡下方新创建的配置,点击详情按钮将文件设置为永久配置文件。

选择构建方式

编写宏文件:回到配置选择页面,点击详情右侧的编写脚步(也就是小太阳图标),将完整宏文件粘贴并替换掉原有代码。

宏文件导入:点击右侧的导入按钮,选择你保存的 lua 宏文件,点击导入即可。

四、鼠标按键功能说明与完整 Lua 宏代码

罗技G502按键:

G1 - 鼠标左键(未标示)

G2 - 鼠标右键(未标示)

G3 - 鼠标中键(滚轮按下)

G4 - 上一页(网页)

G5 - 下一页(网页)

G6 - 暂时降低指标速度做精密操作(拇指前方那颗,标示为准心)

G7 - DPI 降低(降低指标速度)

G8 - DPI 增加(提高指标速度)

G9 - 在多套内存设定间切换`

G10 - 左横向卷动(滚轮左倾)

G11 - 右横向卷动(滚轮右倾)

* - 滚轮模式切换(G9 前方那颗)

罗技G502键位图解:

完整代码

----所有功能默认不启用,设置为0,请自行启动需要的功能----

offkey = 3 -----------------总开关按键(默认滚轮)---开启/关闭----------

kaiguan = true

-------------------------------------------------------------------------------------------

---------------所有按键都不可出现重复:即出现两个相同的数值--------------------------

--------------------对应压枪功能打开后左键开枪自动压枪------------------------------

-----------------------!!!支持所有侧键!!!---------------------------------

qbz = 0 ---------开启QBZ压枪按键--

m4 = 0 ---------开启M4压枪按键---

ak = 0 ---------开启AK压枪按键---

------------------------------------------------------------------------------------------

------------------!!!Alt+侧键开启压枪功能区!!!------------------------------------

---------按下滚轮开启宏后,再按下ALT+对应侧键打开压枪功能,打开后左键开枪自动压枪-----------

---------------------开启下一把枪自动关闭上一把枪的数据,不会混乱--------------------------

alt_qbz = 0 ---------ALT+该侧键开启QBZ压枪--

alt_m4 = 0 ---------ALT+该侧键开启M4压枪--

alt_ak = 0 ---------ALT+该侧键开启AK压枪--

------------------------------------------------------------------------------------------

-- 注释:该功能区的意义在于照顾侧键少的宝贝。举个例子:将qbz_alt=5:即设置为alt+侧键5开启,同时将炼狱无后座开火也绑定到侧键5,此时单按侧键5是炼狱无后座,按着ALT+侧键5就是开启QBZ压枪--

------------------------------------------------------------------------------------------

------------!!以下区域参数仅更新时改动!!--------------

V_down = 30

--------------以下区域根据自己游戏灵敏度调,调完之后一定要记得备份一下自己的压枪数值,以便后续脚本更新替换!!!-----------

-------------QBZ数据区--------------------------------

------------------------------------------------------

qbz_limite = 120

qbz_guntime = 60

qbz_power = {5, 6, 5, 4, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 6, 5, 6, 5, 6, 5, 6}

------------------------------------------------------

-------------M4数据区----------------------------------

-------------------------------------------------------

m4_limite = 120

m4_guntime = 50

m4_power = {6, 5, 6, 5, 6, 5, 6, 5, 5, 6, 5, 6, 5, 6, 5, 7, 5, 6, 7, 6, 5}

-------------------------------------------------------

-------------------------------------------------------

-------------AK数据区-----------------------------------

ak_limite = 210

ak_guntime = 40

ak_power = {

11, 9, 10, 9, 10, 9, 10, 9, 10, 10, 9, 10, 9, 10, 9, 11, 9, 10, 11, 10, 9,

11

}

-------------------------------------------------------------

---------------------------左键开火区域,游戏记得改开火,开启侧键为任意,改了游戏开火就别用压枪功能--------------------

---------------------------使用方法:大写键盘开启后,然后按对应功能侧键再按左键开火就行------------------------------

---------------------------普通模式就是关闭大写键盘后,按下普通模式开启侧键,如果不需要开关就把false改为true----------

normal = 0 ------------普通模式开启侧键--------

putong = false ------------如果不想用开关就把false改为true-------

fire_key = "p" ------游戏改开火键-----------

z_lianyu = 1 ------左键炼狱---------

z_lianyumin = 100

z_lianyumax = 185

z_lianyumin1 = 10

z_lianyumax1 = 25

z_usp = 0 --------左键usp--------

z_uspmin = 26

z_uspmax = 55

z_uspmin1 = 33

z_uspmax1 = 66

-------------这区域不用管-------------------

lianyu_num = 1

usp_num = 2

gun = 0

Script_Switch = "capslock" -------左键模式判别---------

--------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------

-----------------这个区域只能4,5号侧键(可一直按,松就停)------------------------

guitiao = 0 -----------------鬼跳(无需按蹲版)--------------------

GMIN = 5

GMAX = 25

GMIN1 = 10

GMAX1 = 28

hk417 = 0 -----------------hk417--------------------

hk_min = 100

hk_max = 130

lianyusuci = 0 ---------------炼狱速刺-----------

suibu = 0 -----------------碎步--------------------

sandun = 0 -----------------闪蹲--------------------

liudan = 0 ----------------爆裂者榴弹----------------

tangdao = 0 -------------------唐刀速砍--------------

lianyu = 5 -----------------炼狱--------------------

lianyumin = 100

lianyumax = 185

usp1 = 0 -----------------USP普通版--------------------

uspmin = 29

uspmax = 59

uspmin1 = 40

uspmax1 = 70

usp = 0 -----------------USP下压版--------------------

usppower = 40

uspmin_1 = 30

uspmax_1 = 60

uspmin1_1 = 40

uspmax1_1 = 70

usp2 = 4 -----------------USP重置版--------------------

uspmin_2 = 24

uspmax_2 = 36

uspmin2_2 = 36

uspmax2_2 = 57

-----------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------

---------------------这个区域任意侧键(按了就松,别一直按!!!)--------------------

leishen = 0 -----------------雷神(可以左键)--------------------

m4_min = 80 ---------------雷神(打不出第4发加这个毫秒)-------------

m4_max = 85 ---------------雷神(打不出第4发加这个毫秒)-------------

xukong = 0 ------------------虚空卡刀----------------

liujitiao = 0 -----------------六级跳--------------------

chaojitiao = 0 -----------------超级跳(准星斜45度)--------------------

erjitiao = 0 -----------------二级跳--------------------

shunju = 0 ---------瞬狙(可以右键)-----------------

shunju_switch = false -------如果想用右键长按是架狙,就把这里的false改为true,为右键瞬狙设置的-------

sleep_time = 40 --------瞬狙延迟开火毫秒,可以设大一点拿来打队伤------

---------------------------盲狙加下面这区域毫秒---------------

min = 10 -----------瞬狙右键持续最低毫秒---------------

max = 30 -----------瞬狙右键持续最高毫秒---------------

min1 = 10 ---------瞬狙左键按下持续最低毫秒---------

max1_1 = 30 ----------瞬狙左键按下持续最高毫秒---------

------------------------------------------

------------只切刀改这里---------------

qiehuan = "q" ---------瞬狙切换刀就改成3(默认q切上一把)---------

qiehuan1 = "q" ---------瞬狙切换刀就改成1(默认q切上一把)--------

--------------------------------------------------

-------------切不回狙加大这里毫秒-------------

mintime_q = 120 ---------切枪速度最小值--

maxtime_q = 250 ---------切枪速度最大值--

----------------------------------------------------------------------------------------

timelimit = "3023/11/30 00:00:00"

function OnEvent(event, arg)

uy = usppower

EnablePrimaryMouseButtonEvents(true)

if (event == "MOUSE_BUTTON_PRESSED" and arg == offkey) then

kaiguan = not kaiguan

pressgunqbz = false

pressgunm4 = false

pressgunak = false

if (kaiguan) then

ClearLog()

OutputLogMessage(" on \n")

else

ClearLog()

OutputLogMessage(" off \n")

end

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == alt_qbz and kaiguan and

IsModifierPressed("lalt")) then

pressgunqbz = true

pressgunm4 = false

pressgunak = false

ClearLog()

OutputLogMessage("QBZ_ON ! ! !\n")

sleep_guntime = qbz_guntime

gun_power = qbz_power

gun_limite = qbz_limite

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == alt_m4 and kaiguan and

IsModifierPressed("lalt")) then

pressgunqbz = false

pressgunm4 = true

pressgunak = false

ClearLog()

OutputLogMessage("M4_ON ! ! !\n")

sleep_guntime = m4_guntime

gun_power = m4_power

gun_limite = m4_limite

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == alt_ak and kaiguan and

IsModifierPressed("lalt")) then

pressgunqbz = false

pressgunm4 = false

pressgunak = true

ClearLog()

OutputLogMessage("AK_ON ! ! !\n")

sleep_guntime = ak_guntime

gun_power = ak_power

gun_limite = ak_limite

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == qbz and kaiguan and

not IsModifierPressed("lalt")) then

pressgunqbz = true

pressgunm4 = false

pressgunak = false

ClearLog()

OutputLogMessage("QBZ_ON ! ! !\n")

sleep_guntime = qbz_guntime

gun_power = qbz_power

gun_limite = qbz_limite

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == m4 and kaiguan and

not IsModifierPressed("lalt")) then

pressgunm4 = true

pressgunqbz = false

pressgunak = false

ClearLog()

OutputLogMessage("M4_ON ! ! !\n")

sleep_guntime = m4_guntime

gun_power = m4_power

gun_limite = m4_limite

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == ak and kaiguan and

not IsModifierPressed("lalt")) then

pressgunak = true

pressgunm4 = false

pressgunqbz = false

ClearLog()

OutputLogMessage("AK_ON ! ! !\n")

sleep_guntime = ak_guntime

gun_power = ak_power

gun_limite = ak_limite

end

if pressgunqbz or pressgunm4 or pressgunak then

i = 1

y = 1

if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then

Sleep(sleep_guntime)

while (IsMouseButtonPressed(1)) do

MoveMouseRelative(0, gun_power[i])

i = i + 1

y = y + i

Sleep(V_down)

end

end

if not IsMouseButtonPressed(1) then

if y > gun_limite then

y = gun_limite

MoveMouseRelative(0, -y)

else

MoveMouseRelative(0, -y)

end

end

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == lianyusuci and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("lianyusuci_ing\n")

repeat

PressMouseButton(3)

Sleep(math.random(162, 170))

ReleaseMouseButton(3)

Sleep(math.random(121, 130))

PressMouseButton(1)

Sleep(math.random(30, 50))

ReleaseMouseButton(1)

Sleep(math.random(20, 30))

until not IsMouseButtonPressed(lianyusuci)

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == hk417 and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("hk417_ing\n")

repeat

PressMouseButton(1)

Sleep(math.random(25, 50))

ReleaseMouseButton(1)

Sleep(math.random(100, 130))

until not IsMouseButtonPressed(hk417)

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == liujitiao and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("liujitiao_ing\n")

PressKey("s")

Sleep(1217)

PressKey("w")

Sleep(300)

PressKey("lctrl")

Sleep(30)

ReleaseKey("lctrl")

Sleep(10)

PressKey("lctrl")

Sleep(30)

ReleaseKey("lctrl")

Sleep(10)

PressKey("spacebar")

Sleep(math.random(105, 107))

PressKey("lctrl")

Sleep(85)

ReleaseKey("spacebar")

Sleep(135)

ReleaseKey("lctrl")

Sleep(1000)

PressKey("spacebar")

Sleep(math.random(105, 107))

PressKey("lctrl")

Sleep(85)

ReleaseKey("spacebar")

Sleep(135)

ReleaseKey("lctrl")

Sleep(1000)

PressKey("spacebar")

Sleep(math.random(105, 107))

PressKey("lctrl")

Sleep(85)

ReleaseKey("spacebar")

Sleep(135)

ReleaseKey("lctrl")

Sleep(1000)

ReleaseKey("w")

Sleep(500)

PressKey("spacebar")

Sleep(136)

ReleaseKey("spacebar")

Sleep(500)

PressKey("spacebar")

Sleep(135)

ReleaseKey("spacebar")

Sleep(106)

PressKey("lctrl")

Sleep(30)

ReleaseKey("lctrl")

Sleep(60)

PressKey("spacebar")

Sleep(107)

ReleaseKey("spacebar")

Sleep(math.random(105, 107))

ReleaseKey("s")

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == leishen and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("leishen_ing\n")

PressMouseButton(1)

Sleep(math.random(35, 37))

ReleaseMouseButton(1)

Sleep(math.random(68, 70))

PressMouseButton(1)

Sleep(math.random(43, 45))

ReleaseMouseButton(1)

Sleep(math.random(31, 35))

PressMouseButton(1)

Sleep(math.random(24, 26))

ReleaseMouseButton(1)

Sleep(math.random(m4_min, m4_max))

PressMouseButton(1)

Sleep(math.random(43, 45))

ReleaseMouseButton(1)

Sleep(20)

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == usp and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("usp_ing\n")

repeat

PressMouseButton(1)

Sleep(math.random(uspmin_1, uspmax_1))

MoveMouseRelative(0, uy)

ReleaseMouseButton(1)

Sleep(math.random(uspmin1_1, uspmax1_1))

uy = 0

until not IsMouseButtonPressed(usp)

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == usp1 and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("usp1_ing\n")

repeat

PressMouseButton(1)

Sleep(math.random(uspmin, uspmax))

ReleaseMouseButton(1)

Sleep(math.random(uspmin1, uspmax1))

until not IsMouseButtonPressed(usp1)

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == usp2 and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("usp2_ing\n")

repeat

PressMouseButton(1)

Sleep(math.random(uspmin_2, uspmax_2))

ReleaseMouseButton(1)

Sleep(math.random(uspmin2_2, uspmax2_2))

until not IsMouseButtonPressed(usp2)

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == lianyu and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("lianyu_ing\n")

repeat

PressMouseButton(1)

Sleep(math.random(lianyumin, lianyumax))

ReleaseMouseButton(1)

Sleep(math.random(10, 25))

until not IsMouseButtonPressed(lianyu)

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == chaojitiao and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("chaojitiao_ing\n")

PressKey("s")

Sleep(5)

PressKey("w")

Sleep(600)

PressKey("lctrl")

Sleep(30)

ReleaseKey("lctrl")

Sleep(100)

PressKey("lctrl")

Sleep(30)

ReleaseKey("lctrl")

Sleep(20)

PressKey("spacebar")

Sleep(107)

PressKey("lctrl")

Sleep(85)

ReleaseKey("spacebar")

Sleep(135)

ReleaseKey("lctrl")

ReleaseKey("s")

ReleaseKey("w")

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == erjitiao and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("erjitiao_ing\n")

PressKey("spacebar")

Sleep(math.random(183, 185))

ReleaseKey("spacebar")

Sleep(math.random(430, 440))

PressKey("spacebar")

Sleep(math.random(170, 175))

PressKey("lctrl")

Sleep(15)

ReleaseKey("spacebar")

Sleep(132)

ReleaseKey("lctrl")

Sleep(30)

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == guitiao and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("guitiao_ing\n")

PressKey("spacebar")

Sleep(math.random(GMIN, GMAX))

PressKey("lctrl")

Sleep(30)

ReleaseKey("spacebar")

Sleep(math.random(GMIN1, GMAX1))

repeat

PressKey("spacebar")

Sleep(math.random(GMIN, GMAX))

ReleaseKey("spacebar")

Sleep(math.random(GMIN1, GMAX1))

until not IsMouseButtonPressed(guitiao)

ReleaseKey("lctrl")

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == guitiao1 and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("guitiao1_ing\n")

repeat

PressKey("spacebar")

Sleep(math.random(GMIN2, GMAX2))

ReleaseKey("spacebar")

Sleep(math.random(GMIN2_1, GMAX2_1))

until not IsMouseButtonPressed(guitiao1)

end

if shunju_switch then

if (event == "MOUSE_BUTTON_RELEASED" and kaiguan and arg == shunju and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage(" shunju_ing")

PressMouseButton(1)

Sleep(math.random(min1, max1_1))

ReleaseMouseButton(1)

Sleep(math.random(15, 30))

PressKey(qiehuan)

Sleep(math.random(25, 55))

ReleaseKey(qiehuan)

Sleep(math.random(mintime_q, maxtime_q))

PressKey(qiehuan1)

Sleep(math.random(40, 55))

ReleaseKey(qiehuan1)

end

elseif (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == shunju and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage(" shunju_ing")

Sleep(sleep_time)

PressMouseButton(3)

Sleep(math.random(min, max))

PressMouseButton(1)

Sleep(math.random(min1, max1_1))

ReleaseMouseButton(3)

Sleep(math.random(15, 25))

ReleaseMouseButton(1)

Sleep(math.random(15, 30))

PressKey(qiehuan)

Sleep(math.random(25, 55))

ReleaseKey(qiehuan)

Sleep(math.random(mintime_q, maxtime_q))

PressKey(qiehuan1)

Sleep(math.random(40, 55))

ReleaseKey(qiehuan1)

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == suibu and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("suibu_ing\n")

repeat

PressKey("w")

Sleep(math.random(10, 50))

ReleaseKey("w")

Sleep(math.random(20, 65))

until not IsMouseButtonPressed(suibu)

end

if (event == "MOUSE_BUTTON_PRESSED" and offkey and arg == liudan and

not IsModifierPressed("lalt")) then

repeat

OutputLogMessage(" liudan_ing \n")

PressMouseButton(3)

Sleep(math.random(40, 45))

ReleaseMouseButton(3)

Sleep(math.random(15, 20))

until not IsMouseButtonPressed(liudan)

end

if (event == "MOUSE_BUTTON_PRESSED" and offkey and arg == tangdao and

not IsModifierPressed("lalt")) then

repeat

PressMouseButton(1)

Sleep(math.random(50, 55))

ReleaseMouseButton(1)

Sleep(math.random(360, 380))

until not IsMouseButtonPressed(tangdao)

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == xukong and

not IsModifierPressed("lalt")) then

PressMouseButton(3)

Sleep(math.random(300, 320))

ReleaseMouseButton(3)

Sleep(math.random(300, 350))

PressKey("f")

Sleep(math.random(10, 15))

ReleaseKey("f")

Sleep(math.random(10, 20))

PressKey("f")

Sleep(math.random(10, 20))

ReleaseKey("f")

Sleep(math.random(10, 30))

PressMouseButton(3)

Sleep(math.random(157, 165))

ReleaseMouseButton(3)

Sleep(math.random(38, 45))

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == erlianfa) then

ClearLog()

OutputLogMessage("erlianfa_ing\n")

PressMouseButton(1)

Sleep(math.random(35, 37))

ReleaseMouseButton(1)

Sleep(math.random(68, 70))

PressMouseButton(1)

Sleep(math.random(43, 45))

ReleaseMouseButton(1)

Sleep(math.random(31, 35))

end

if (event == "MOUSE_BUTTON_PRESSED" and kaiguan and arg == sandun and

not IsModifierPressed("lalt")) then

ClearLog()

OutputLogMessage("sandun_ing\n")

repeat

PressKey("lctrl")

Sleep(math.random(15, 17))

ReleaseKey("lctrl")

Sleep(math.random(15, 17))

PressKey("lctrl")

Sleep(math.random(15, 17))

ReleaseKey("lctrl")

until not IsMouseButtonPressed(sandun)

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == z_lianyu) then

if gun == lianyu_num then

gun = 0

ClearLog()

OutputLogMessage(" lianyu_off \n")

else

gun = lianyu_num

ClearLog()

OutputLogMessage(" lianyu_on \n")

end

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == z_usp) then

if gun == usp_num then

gun = 0

ClearLog()

OutputLogMessage(" usp_off \n")

else

gun = usp_num

ClearLog()

OutputLogMessage(" usp_on \n")

end

end

if (event == "MOUSE_BUTTON_PRESSED" and arg == normal) then

putong = not putong

if putong then

OutputLogMessage(" putong_on \n")

else

OutputLogMessage(" putong_off \n")

end

end

if gun == lianyu_num and IsKeyLockOn(Script_Switch) then

if IsMouseButtonPressed(1) then

ClearLog()

OutputLogMessage(" lianyu_ing\n")

repeat

PressKey(fire_key)

Sleep(math.random(z_lianyumin, z_lianyumax))

ReleaseKey(fire_key)

Sleep(math.random(z_lianyumin1, z_lianyumax1))

until not IsMouseButtonPressed(1)

end

end

if gun == usp_num and IsKeyLockOn(Script_Switch) then

if IsMouseButtonPressed(1) then

ClearLog()

OutputLogMessage(" usp_ing\n")

repeat

PressKey(fire_key)

Sleep(math.random(z_uspmin, z_uspmax))

ReleaseKey(fire_key)

Sleep(math.random(z_uspmin1, z_uspmax1))

until not IsMouseButtonPressed(1)

end

end

if gun == usp_num and IsKeyLockOn(Script_Switch) then

if IsMouseButtonPressed(1) then

ClearLog()

OutputLogMessage(" usp_ing\n")

repeat

PressKey(fire_key)

Sleep(math.random(z_uspmin, z_uspmax))

ReleaseKey(fire_key)

Sleep(math.random(z_uspmin1, z_uspmax1))

until not IsMouseButtonPressed(1)

end

else

if IsMouseButtonPressed(1) and putong then

PressKey(fire_key)

else

ReleaseKey(fire_key)

end

end

end

五、保存并测试宏

保存宏代码:在 Ghub 的宏编辑界面中,将编写好的 Lua 代码复制粘贴进去,然后点击 “保存并运行” 按钮。

测试宏:打开一个可以测试鼠标点击的界面,按下你设置的触发宏的按键,检查宏是否正常工作。如果有问题,可以返回宏编辑界面修改代码。

六、注意事项

遵守游戏规则:在 CF 正式服中使用自定义宏可能违反游戏规则,导致账号被封禁,因此仅可在非官方认可的测试环境或娱乐场景中使用。

代码调试:编写宏代码时,可能需要多次调整参数,如点击间隔时间、点击次数等,以达到最佳效果。

希望这篇教程能帮助你学会使用 CF 宏文件进行简单的编程和操作。

测试 Lua 穿越火线 Game

相关文章