lua csgo 您所在的位置:网站首页 csgo的iq lua csgo

lua csgo

2024-07-10 22:55| 来源: 网络整理| 查看: 265

利用罗技官方提供的API来写一个鼠标自动定位移动脚本

  点击脚本编辑器中的帮助选项,查看罗技官方提供的API说明,有很多实现好的鼠标功能

  

 

   G-series Lua API V8.45 Overview and Reference

  

   下面是我写的一个自动压枪代码。在csgo游戏中实现SG553,AUG两种步枪的自动压枪功能,以及通用武器自动压枪功能

   

1 --全局变量区 2 condition = false --功能启用状态开关 3 weapon = nil --当前所用的武器 4 5 --武器弹道参数-------------------------------------------------------------------------- 6 --AUG步枪 7 onWeaponAUG = function() 8 local arr = {} 9 local arrLength = 30 10 local weaponDuration = 150 11 local x ={} 12 local y ={} 13 14 x[2]=0 y[2]=10 15 x[3]=0 y[3]=10 16 x[4]=0 y[4]=10 17 x[5]=0 y[5]=20 18 x[6]=0 y[6]=60 19 x[7]=15 y[7]=60 20 x[8]=15 y[8]=60 21 x[9]=15 y[9]=60 22 x[10]=20 y[10]=50 23 x[11]=10 y[11]=0 24 x[12]=0 y[12]=0 25 x[13]=0 y[13]=0 26 x[14]=0 y[14]=0 27 x[15]=-30 y[15]=0 28 x[16]=-50 y[16]=0 29 x[17]=-50 y[17]=0 30 x[18]=-30 y[18]=0 31 x[19]=-30 y[19]=0 32 x[20]=-30 y[20]=0 33 x[21]=40 y[21]=0 34 x[22]=40 y[22]=0 35 x[23]=40 y[23]=0 36 x[24]=40 y[24]=0 37 x[25]=40 y[25]=0 38 x[26]=40 y[26]=0 39 x[27]=-10 y[27]=0 40 x[28]=-10 y[28]=0 41 x[29]=0 y[29]=0 42 x[30]=0 y[30]=0 43 44 arr[0] = x 45 arr[1] = y 46 arr[2] = weaponDuration 47 arr[3] = arrLength 48 return arr 49 end 50 ---------------------------------------------------------------------------- 51 --SG553步枪 52 onWeaponSG553 = function() 53 local arr= {} 54 local arrLength = 30 55 local weaponDuration = 150 56 local x ={} 57 local y ={} 58 59 x[2]= -4 y[2]=10 60 x[3]=-4 y[3]=20 61 x[4]=-40 y[4]=50 62 x[5]=-10 y[5]=20 63 x[6]=-30 y[6]=20 64 x[7]=-40 y[7]=20 65 x[8]=-15 y[8]=20 66 x[9]=-15 y[9]=20 67 x[10]=-15 y[10]=20 68 x[11]=-5 y[11]=20 69 x[12]=-30 y[12]=30 70 x[13]=-30 y[13]=20 71 x[14]=0 y[14]=50 72 x[15]=0 y[15]=15 73 x[16]=0 y[16]=15 74 x[17]=-20 y[17]=-20 75 x[18]=-20 y[18]=-20 76 x[19]=-30 y[19]=50 77 x[20]=0 y[20]=-20 78 x[21]=0 y[21]=-20 79 x[22]=80 y[22]=-20 80 x[23]=80 y[23]=-20 81 x[24]=50 y[24]=20 82 x[25]=30 y[25]=20 83 x[26]=30 y[26]=50 84 x[27]=30 y[27]=20 85 x[28]=-30 y[28]=20 86 x[29]=-50 y[29]=20 87 x[30]=-80 y[30]=20 88 89 arr[0] = x 90 arr[1] = y 91 arr[2] = weaponDuration 92 arr[3] = arrLength 93 return arr 94 end 95 ---------------------------------------------------------------------------- 96 --通用武器 97 onWeaponAll = function() 98 local arr= {} 99 local arrLength = 15 100 local weaponDuration = 150 101 local x ={} 102 local y ={} 103 104 x[2]=0 y[2]=15 105 x[3]=0 y[3]=15 106 x[4]=0 y[4]=15 107 x[5]=0 y[5]=15 108 x[6]=0 y[6]=20 109 x[7]=0 y[7]=25 110 x[8]=0 y[8]=25 111 x[9]=0 y[9]=25 112 x[10]=0 y[10]=25 113 x[11]=0 y[11]=25 114 x[12]=0 y[12]=25 115 x[13]=0 y[13]=25 116 x[14]=0 y[14]=25 117 x[15]=0 y[15]=25 118 119 arr[0] = x 120 arr[1] = y 121 arr[2] = weaponDuration 122 arr[3] = arrLength 123 return arr 124 end 125 ---------------------------------------------------------------------------- 126 --入口函数 127 function OnEvent(event,arg) 128 --控制台格式化输出当前的按健 129 --OutputLogMessage("event = %s, arg = %d\n", event, arg) 130 activate(event,arg) 131 decide(event,arg) 132 end 133 134 --------------------------------------------------------------------------- 135 --激活鼠标按健报告函数 136 activate = function(event,arg) 137 if (event == "PROFILE_ACTIVATED") then --配置文件被激活 138 EnablePrimaryMouseButtonEvents(true) --启用鼠标按健1的事件报告 139 elseif event == "PROFILE_DEACTIVATED" then        --配置文件没有被激活 140 EnablePrimaryMouseButtonEvents(false) --禁用鼠标按健1的事件报告 141 end 142 end 143 144 --------------------------------------------------------------------------- 145 --功能判断函数 146 decide = function(event,arg) 147 if event == "MOUSE_BUTTON_PRESSED" and arg == 6 then -- 按下6键 关闭压枪功能 148 ClearLog() 149 OutputLogMessage(">>>OFF\n") 150 condition = false 151 weapon = nil 152 elseif event == "MOUSE_BUTTON_PRESSED" and arg == 4 then -- 按下4键 选择SG553步枪 153 ClearLog() 154 OutputLogMessage(">>>USING SG553") 155 condition = true 156 weapon = onWeaponSG553() 157 elseif event == "MOUSE_BUTTON_PRESSED" and arg == 5 then -- 按下5键 选择aug步枪 158 ClearLog() 159 OutputLogMessage(">>>USING AUG") 160 condition = true 161 weapon = onWeaponAUG() 162 elseif event == "MOUSE_BUTTON_PRESSED" and arg == 7 then -- 按下5键 选择aug步枪 163 ClearLog() 164 OutputLogMessage(">>>USING All") 165 condition = true 166 weapon = onWeaponAll() 167 elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 and condition == true then --按住鼠标1键 自动开火并鼠标自动压枪 168 fire(weapon) 169 end 170 end 171 172 --------------------------------------------------------------------------- 173 --武器开火,执行功能函数 174 fire = function ( parametersArr ) 175 local arr = parametersArr 176 local arrX = arr[0] 177 local arrY = arr[1] 178 local weaponDuration = arr[2] 179 local length = arr[3] 180 181 182 for x=2,length,1 do 183 for y=x,length,1 do 184 if moveMouse(arrX[x],arrY[y],weaponDuration) == false then break end 185 break 186 end 187 end 188 end 189 190 ---------------------------------------------------------------------------- 191 --鼠标自动移动函数 192 moveMouse = function(x,y,time) 193 if IsMouseButtonPressed(1) then 194 MoveMouseRelative(x,y) 195 Sleep(time) 196 return true 197 else 198 return false 199 end 200 end

 

代码功能

  以上代码按健的配置是基于罗技G502鼠标,其它

  按下鼠标6键关闭自动控制功能

  按下鼠标7 键开启指定武器鼠标控制

  按下鼠标5 键开启指定武器鼠标控制

  按下鼠标4 键开启指定武器鼠标控制

  按住鼠标1 键,检查自动控制功能是否开启,如果开启便调用指定函数执行

 

关键功能函数说明,具体使用说明请参考官方说明文档

  MoveMouseRelative(x,y) 移动鼠标指针至当前屏幕中的目标绝对坐标位置  Sleep(time)  暂停脚本并等待所设置的时间后再继续执行 OnEvent() 方法为脚本提供了一系列事件句柄以方便用户对触发的事件进行操  OutputLogMessage() 在控制台输出指定内容  EnablePrmaryMouseButtonEvent() 开启鼠标1键的事件报告

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有