This repository was archived by the owner on Jul 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.lua
More file actions
2460 lines (2457 loc) · 103 KB
/
Copy pathmain.lua
File metadata and controls
2460 lines (2457 loc) · 103 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
require "TSLib"
local ts = require("ts")
local sz = require("sz")
local json = sz.json
init(1)
apiUrl = "https://yourdomin.cn/a9api/"
gameBid = "com.Aligames.kybc9"
root = userPath() .. "/res/"
stage = -1 --段位
state = 0 --中间变量,声明检测界面后的下一步流程
path = 0 --道路选择
time = -1 --时间戳,记录离开赛事的时间
innerGhost = 0 --有内鬼次数
LoginTimes = 0 --连续登陆次数
PVPTimes, PVETimes = 0, 0 --多人和赛事局数,存文件
width, height = 0, 0 --屏幕分辨率
checkplacetimes = 0 --连续检测界面次数
checkplacetimesout = 35 --连续检测界面超时次数
validateGame = false --是否已知处在正确的赛事位置
runningState = true --脚本运行状态
receive_starting_command = false --如果是true那么检测到账号被顶就不再等待
changecar = false --PVE是否已经换车
PVPchooseCar = true --多人是否选车
model = "" --设备型号
chooseHighStageCarClass = 1 --改成1的话,使用新多人选车方案
watchAds = ""
PVPwithoutPack, packWithoutRestore = 0, 0 --开过最近的一个PVP包后完成PVP局数,连着开了多少个包但是没有补充
accountnum, nowaccount = "", "" --当前运行的账号,当前运行的账号+密码
switchaccountfun = false --是否打开多人刷包切换账号的功能
udid = ts.system.udid()
settings = ""--用户设置
noAds, restartTimes = 0, 0 --连续回油没广告次数,连续重启次数
---前置准备函数---
function prepare()
unlockedDevice()
setAutoLockTime(0)
checkScreenSize()
networkState()
starttime = os.time()
ShowUI()
period = os.time() - starttime - 2--period>115认为没有点确定,无人为操作,脚本远程启动
--获取上次的设置(远端设置),然后对比这次的设置,若改动,就用改过的并在远端保存此次改过的设置,若无改动,就判断是不是period>115脚本远程启动,如果是就使用远端设置,远端设置可以提前获取。
if period > 115 then
refreshSettings(getSettings())
else
saveSettings()
end
initTable()
startGame()
savePowerF()
paraArgu()
end
---程序主函数---
function main()
prepare()
:: begin ::
worker(checkPlace())
if state ~= -1 then
checkplacetimes = 0
end
if state == -1 then
checkplacetimes = checkplacetimes + 1
goto begin
elseif state == -2 then
goto stop
elseif state == -3 then
goto begin
elseif state == -4 then
goto backFromLines
elseif state == -5 then
goto autoMobile
elseif state == -6 then
goto waitBegin
end
state = toCarbarn()--此处的state=-1 0 1 分别对应停止 中断再识别 继续
if state == 0 then
goto begin
elseif state == -1 then
goto stop
end
:: chooseCar ::
if not chooseCar() then
goto begin --选车出错了
end
:: waitBegin ::
if waitBegin() == -1 then
goto begin
end
:: autoMobile ::
autoMobile()
:: backFromLines ::
backFromLines()
if not shouldStop(false) then
goto begin
end
:: stop ::
after()
end
---结束处理函数---
function after()
log4l("⏹脚本停止运行")
closeApp(gameBid) --关闭游戏
lockDevice()
end
function beforeUserExit()
ts.httpsGet(apiUrl .. "a9control?udid=" .. udid .. "&command=1", {}, {})
log4l("⏹脚本被手动终止")
end
---通用处理函数[不区分设备型号]---
function drift(second)
touchDown(150, 550);
mSleep(second * 1000);
touchUp(150, 550);
end
function saveSettings()
--存储用户本次设置选项
body_send = { ["udid"] = udid, ["settings"] = settings }
ts.httpsPost(apiUrl .. "a9saveSettings", {}, body_send)
end
function getSettings()
--存储用户本次设置选项
newsettings = settings
a9getSettings_code, a9getSettingsheader_resp, resp_settings = ts.httpsGet(apiUrl .. "a9getSettings?udid=" .. udid, {}, {})
if a9getSettings_code == 200 then
newsettings = resp_settings
end
return newsettings
end
function refreshSettings(newsettings)
if not (settings == newsettings) and not (newsettings == nil) then
settingsTable = strSplit(settings, "|")
newsettingsTable = strSplit(newsettings, "|")
refreshSettingslog = ""
for key, value in pairs(newsettingsTable) do
if not (settingsTable[key] == newsettingsTable[key]) then
if (key == 1) then
supermode = value
mode = value
refreshSettingslog = refreshSettingslog .. "主模式更改为" .. value .. " "
elseif (key == 2) then
switch = value
mode = supermode
refreshSettingslog = refreshSettingslog .. "没油没票后动作(赛事模式)更改为" .. value .. " "
elseif (key == 3) then
path = value
refreshSettingslog = refreshSettingslog .. "路线选择(所有模式)更改为" .. value .. " "
elseif (key == 4) then
gamenum = value
validateGame = false
refreshSettingslog = refreshSettingslog .. "赛事位置选择更改为" .. value .. " "
elseif (key == 5) then
PVEchooseCar = value
refreshSettingslog = refreshSettingslog .. "赛事是否选车更改为" .. value .. " "
elseif (key == 6) then
carplace = value
refreshSettingslog = refreshSettingslog .. "赛事用车位置选择(赛事模式)更改为" .. value .. " "
elseif (key == 7) then
backifallstar = value
refreshSettingslog = refreshSettingslog .. "赛事选车是否返回一次(被寻车满星时)更改为" .. value .. " "
elseif (key == 8) then
PVPatBest = value
refreshSettingslog = refreshSettingslog .. "传奇是否刷多人更改为" .. value .. " "
elseif (key == 9) then
savePower = value
refreshSettingslog = refreshSettingslog .. "节能模式更改为" .. value .. " "
elseif (key == 10) then
lowerCar = value
refreshSettingslog = refreshSettingslog .. "多人选低一段车辆(白银及以上)更改为" .. value .. " "
elseif (key == 11) then
changeCar = value
refreshSettingslog = refreshSettingslog .. "赛事没油是否换车更改为" .. value .. " "
elseif (key == 12) then
watchAds = value
refreshSettingslog = refreshSettingslog .. "赛事没油是否看广告更改为" .. value .. " "
elseif (key == 13) then
timeout_backPVE = value
refreshSettingslog = refreshSettingslog .. "需要过多久返回赛事模式或寻车模式更改为" .. value .. " "
elseif (key == 14) then
skipcar = value
refreshSettingslog = refreshSettingslog .. "多人跳车更改为" .. value .. " "
elseif (key == 15) then
timeout_parallelRead = value
refreshSettingslog = refreshSettingslog .. "顶号重连更改为" .. value .. " "
elseif (key == 16) then
email = value
refreshSettingslog = refreshSettingslog .. "邮箱更改为" .. value .. "@qq.com"
end
end
end
log4l(refreshSettingslog)
paraArgu()
settings = newsettings
end
end
function savePowerF()
if savePower == "开" then
toast("降低屏幕亮度", 1)
setBacklightLevel(0) --屏幕亮度调制最暗
end
end
function checkScreenSize()
width, height = getScreenSize()
if width == 640 and height == 1136 then
model = "SE"
elseif true or (width == 750 and height == 1334) then
model = "i68"
else
ret = dialogRet("告知\n本脚本不支持您的设备分辨率,是否继续运行此脚本", "是", "否", 0, 0)
if ret ~= 0 then
--如果按下"否"按钮
toast("脚本停止", 1)
mSleep(700)
luaExit() --退出脚本
end
end
end
function splitStr(str)
strLen = getStrNum(str)
restable = {}
for i = 1, strLen do
restable[i] = string.sub(str, i, i)
end
return restable
end
function paraArgu()
math.randomseed(tostring(os.time()):reverse():sub(1, 7)) --随机数初始化
timeout_backPVE = tonumber(timeout_backPVE) --需要过多久返回赛事模式或寻车模式
timeout_parallelRead = tonumber(timeout_parallelRead) --顶号重连时间
gamenum = tonumber(gamenum)
skipcar = tonumber(skipcar)
if path == "左" then
path = -1
elseif path == "中" then
path = 0
elseif path == "右" then
path = 1
elseif path == "随机" then
path = 2
end
if PVEchooseCar == "是" then
PVEchooseCar = true
else
PVEchooseCar = false
end
if PVPchooseCar == "是" then
PVPchooseCar = true
else
PVPchooseCar = false
end
if restartAfterAds == "是" then
restartAfterAds = true
else
restartAfterAds = false
end
supermode = mode
end
function getHttpsCommand()
refreshSettings(getSettings())
:: getCommand ::
a9getCommandcode, a9getCommandheader_resp, a9getCommandbody_resp = ts.httpsGet(apiUrl .. "a9getCommand?udid=" .. udid, {}, {})
if a9getCommandcode == 200 then
a9getCommandbody_resp = tonumber(a9getCommandbody_resp)
if a9getCommandbody_resp == 0 then
if runningState == true then
log4l("⏸接收到暂停指令,脚本暂停运行")
runningState = false
toast("接收到暂停指令,脚本暂停运行", 1)
closeApp(gameBid) --关闭游戏
savePowerF()
end
toast("脚本已暂停运行", 4)
mSleep(5000)
toast("5秒后再次发起请求", 4)
mSleep(5000) --等5秒后再次发起请求
goto getCommand
elseif a9getCommandbody_resp == 1 and runningState == false then
toast("接收到开始指令,脚本开始运行", 1)
log4l("▶️接收到开始指令,脚本开始运行")
runningState = true
receive_starting_command = true
savePowerF()
elseif a9getCommandbody_resp == 4 then
toast("接收到脚本停止指令,脚本停止", 1)
log4l("接收到脚本停止指令,脚本停止")
end
if not (a9getCommandbody_resp == 1 and runningState == false) then
ts.httpsGet(apiUrl .. "a9control?udid=" .. udid .. "&command=1", {}, {})--将脚本状态置为运行
end
return a9getCommandbody_resp
end
end
function httpsGet(content)
header_send = {}
body_send = {}
ts.setHttpsTimeOut(5) --安卓不支持设置超时时间
code, header_resp, body_resp = ts.httpsGet(apiUrl .. "a9?content=" .. content .. "&udid=" .. udid, header_send, body_send)
end
function ToStringEx(value)
if type(value) == "table" then
return TableToStr(value)
elseif type(value) == "string" then
return "" .. value .. ""
else
return tostring(value)
end
end
function TableToStr(t)
if t == nil then
return ""
end
local retstr = ""
local i = 1
for key, value in pairs(t) do
local signal = "\n"
if i == 1 then
signal = ""
end
if key == i then
retstr = retstr .. signal .. ToStringEx(value)
else
if type(key) == "number" or type(key) == "string" then
retstr = retstr .. signal .. "[" .. ToStringEx(key) .. "]=" .. ToStringEx(value)
else
if type(key) == "userdata" then
retstr = retstr .. signal .. "*s" .. TableToStr(getmetatable(key)) .. "*e" .. "=" .. ToStringEx(value)
else
retstr = retstr .. signal .. key .. "=" .. ToStringEx(value)
end
end
end
i = i + 1
end
retstr = retstr .. ""
return retstr
end
function url_encode(str)
if (str) then
str = string.gsub(str, "\n", "\r\n")
str = string.gsub(str, "([^%w ])",
function(c)
return string.format("%%%02X", string.byte(c))
end)
str = string.gsub(str, " ", "+")
end
return str
end
function makeGameFront()
if isFrontApp(gameBid) == 0 then
runApp(gameBid)
mSleep(10000)
end
end
function refreshTable()
table = readFile(root .. "A9Info.txt")
if table then
--如果日期不对
if table[1] ~= os.date("%Y年%m月%d日") then
writeFile(root .. "A9Info.txt", { os.date("%Y年%m月%d日"), 0, 0 }, "w", 1)
PVPTimes = 0
PVETimes = 0
writeFile(root .. "A9Info.txt", { os.date("%Y年%m月%d日"), PVPTimes, PVETimes }, "w", 1)
else
writeFile(root .. "A9Info.txt", { os.date("%Y年%m月%d日"), PVPTimes, PVETimes }, "w", 1)
end
else
--没有文件就创建文件,初始化内容
writeFile(root .. "A9Info.txt", { os.date("%Y年%m月%d日"), 0, 0 }, "w", 1)
end
end
function initTable()
table = readFile(root .. "A9Info.txt")
logtxt = readFile(root .. "A9log.txt")
if table then
--如果日期不对,数据重写
if table[1] ~= os.date("%Y年%m月%d日") then
--文件重写
writeFile(root .. "A9Info.txt", { os.date("%Y年%m月%d日"), 0, 0 }, "w", 1)
initTable()
else
PVPTimes = table[2]
PVETimes = table[3]
end
else
--没有文件就创建文件,初始化内容
writeFile(root .. "A9Info.txt", { os.date("%Y年%m月%d日"), 0, 0 }, "w", 1)
mSleep(1000)
initTable() --每次初始化内容都要再运行initTable()检查
end
if logtxt then
if logtxt[1] ~= os.date("%Y年%m月%d日") then
--如果日期不对,发邮件,数据重写
sendEmail(email, "[A9]" .. os.date("%m%d%H") .. "日志" .. getDeviceName(), logtxt)
writeFile(root .. "A9log.txt", { os.date("%Y年%m月%d日") }, "w", 1)
mSleep(1000)
httpsGet("Delete_log")
initTable() --每次初始化内容都要再运行initTable()检查
else
--啥都不干
end
else
--没有文件就创建文件,初始化内容
writeFile(root .. "A9log.txt", { os.date("%Y年%m月%d日") }, "w", 1)
mSleep(1000)
initTable() --每次初始化内容都要再运行initTable()检查
end
end
function log4l(content)
if content ~= "游戏重启" then
restartTimes = 0
end
t = batteryStatus()
charging = ""
if t.charging == 1 then
charging = "⚡"
end
content = content .. " 🔋:️" .. charging .. tostring(t.level) .. "%"
urlcontent = url_encode(content)
table = readFile(root .. "A9log.txt")
if table then
--如果日期不对,发邮件,数据重写
if table[1] ~= os.date("%Y年%m月%d日") then
initTable()
httpsGet("Delete_log")
else
writeFile(root .. "A9log.txt", { "[" .. os.date("%H:%M:%S") .. "]" .. content }, "a", 1)
httpsGet(urlcontent)
end
else
--没有文件就创建文件,初始化内容,再写入内容
initTable()
log4l(content)
end
end
function sendEmail(reciver, topic, content)
if reciver == "" then
toast("未指定邮箱", 1)
return 0
else
reciver = reciver .. "@qq.com"
end
if type(content) == "table" then
content = TableToStr(content)
end
status = ts.smtp(reciver, topic, content, "smtp.qq.com", "yourqq@qq.com", "授权码")
if status then
toast("邮件发送成功", 1)
else
toast("邮件发送失败", 1)
end
mSleep(1000)
end
function networkState()
if getNetTime() == 0 then
ret = dialogRet("无网络连接\n目前设备无网络连接,是否继续运行脚本", "是", "否", 0, 0)
if ret ~= 0 then
--如果按下"否"按钮
toast("脚本停止", 1)
mSleep(700)
luaExit() --退出脚本
end
end
--dialog(networkState() == true and "网络良好" or "无网络")
end
function ShowUI()
w, h = getScreenSize()
UINew(2, "第1页,第2页", "确定", "取消", "uiconfig.dat", 1, 120, w, h, "255,255,255", "255,255,255", "", "dot", 1)
UILabel(1, "狂野飙车9国服iOS脚本", 15, "center", "38,38,38")
UILabel(1, "详细说明,远程控制和远程日志查看请向左滑查看第二页", 20, "left", "255,30,2")
UILabel(1, "购买脚本授权码请联系QQ群1028746490群主", 20, "left", "255,30,2")
UILabel(1, "模式选择", 15, "left", "38,38,38")
UIRadio(1, "mode", "多人刷声望,赛事模式", "0") --记录最初设置 | 特殊赛事保留
UILabel(1, "没油没票后动作(赛事模式)", 15, "left", "38,38,38")
UIRadio(1, "switch", "多人刷声望,等30分钟,等60分钟", "0")
UILabel(1, "路线选择(所有模式)", 15, "left", "38,38,38")
UIRadio(1, "path", "左,中,右,随机", "0")
UILabel(1, "赛事位置选择", 15, "left", "38,38,38")
UIRadio(1, "gamenum", "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22", "0")
UILabel(1, "赛事是否选车", 15, "left", "38,38,38")
UIRadio(1, "PVEchooseCar", "是,否", "0")
UILabel(1, "赛事用车位置选择(赛事模式)", 15, "left", "38,38,38")
UIRadio(1, "carplace", "中间上,中间下,左上,左下,右上(被寻车满星时)", "0")
UILabel(1, "赛事选车是否返回一次(被寻车满星时)", 15, "left", "38,38,38")
UIRadio(1, "backifallstar", "是,否", "0")
UILabel(1, "多人是否选车", 15, "left", "38,38,38")
UIRadio(1, "PVPchooseCar", "是,否", "0")
UILabel(1, "多人类型(如果有)", 15, "left", "38,38,38")
UIRadio(1, "PVPtype", "上,下", "0")
UILabel(1, "传奇是否刷多人", 15, "left", "38,38,38")
UIRadio(1, "PVPatBest", "是,否", "0")
UILabel(1, "节能模式", 15, "left", "38,38,38")
UIRadio(1, "savePower", "开,关", "0")
UILabel(1, "多人选低一段车辆(白银及以上)", 15, "left", "38,38,38")
UIRadio(1, "lowerCar", "开,关", "1")
UILabel(1, "赛事没油是否换车", 15, "left", "38,38,38")
UIRadio(1, "changeCar", "开,关", "0")
UILabel(1, "赛事没油是否看广告(建议配合插件VideoAdsSpeed开20倍使用)", 15, "left", "38,38,38")
UIRadio(1, "watchAds", "开(有20倍广告加速),关,开(没有广告加速)", "0")
UILabel(1, "广告后是否重启游戏", 15, "left", "38,38,38")
UIRadio(1, "restartAfterAds", "是,否", "1")
UILabel(1, "需要过多久返回赛事模式或寻车模式(分钟)", 15, "left", "38,38,38")
UIEdit(1, "timeout_backPVE", "内容", "60", 15, "center", "38,38,38", "number")
UILabel(1, "多人跳车(填0不跳)", 15, "left", "38,38,38")
UIEdit(1, "skipcar", "内容", "0", 15, "center", "38,38,38", "number")
UILabel(1, "顶号重连(分钟)", 15, "left", "38,38,38")
UIEdit(1, "timeout_parallelRead", "内容", "30", 15, "center", "38,38,38", "number")
UILabel(1, "接收日志的QQ邮箱的QQ号", 15, "left", "38,38,38")
UIEdit(1, "email", "邮箱地址(选填)", "", 15, "left", "38,38,38", "default")
UILabel(1, "详细说明请向左滑查看第二页", 20, "left", "255,30,2")
UILabel(2, "本脚本目前适用设备为iPhone 5S/SE/6/6s/7/8/iPod Touch5G(6G),iPad与Plus设备均不支持。", 15, "left", "38,38,38")
UILabel(2, "刷赛事模式需要先用所需车辆手动完成一局再启动脚本。", 15, "left", "255,30,2")
UILabel(2, "多人刷声望:脚本自动刷多人获得声望。", 15, "left", "38,38,38")
--UILabel(2, "多人刷包:脚本自动刷多人包,确保开始时有包可刷。当连续完成12局PVP且12局中未开包时认为刷完,刷完脚本自动停止。", 15, "left", "38,38,38")
UILabel(2, "脚本运行前需手动开启自动驾驶。", 15, "left", "38,38,38")
UILabel(2, "没油没票后动作:刷赛事用完油和票之后的动作,选择去刷多人会在指定时间后返回。", 15, "left", "38,38,38")
UILabel(2, "赛事位置选择:选择刷第几个赛事。", 15, "left", "38,38,38")
UILabel(2, "赛事是否选车:有些赛事为指定车辆,无法从车库选车。", 15, "left", "38,38,38")
UILabel(2, "寻车赛事用车位置选择:赛事选车时游戏会自动跳到上局此赛事所用车辆,需要选择上还是下。", 15, "left", "38,38,38")
UILabel(2, "多人跳车:避免赛事所需车的燃油在多人中消耗,可以指定跳过车辆。", 15, "left", "38,38,38")
UILabel(2, "赛事没油看广告:建议配合插件VideoAdsSpeed开20倍使用。", 15, "left", "38,38,38")
UILabel(2, "接收日志的邮箱:每日日志会在次日脚本运行之初发送至此邮箱。", 15, "left", "38,38,38")
UILabel(2, "远程控制功能,可以访问网址https://yourdomin.cn/api/a9control?command=XXX&udid=" .. ts.system.udid() .. "来远程控制脚本的运行。XXX需要更改为如下几种选项之一:", 15, "left", "38,38,38")
UILabel(2, "XXX=0 暂停脚本运行,与XXX=1配合使用", 15, "left", "38,38,38")
UILabel(2, "XXX=1 恢复脚本运行,与XXX=0配合使用", 15, "left", "38,38,38")
UILabel(2, "XXX=2 停止赛事模式,将主模式更改为多人刷声望,与XXX=3配合使用", 15, "left", "38,38,38")
UILabel(2, "XXX=3 开始赛事模式,将主模式更改为赛事模式,与XXX=2配合使用", 15, "left", "38,38,38")
UILabel(2, "XXX=4 终止脚本运行,此操作不可逆", 15, "left", "38,38,38")
UILabel(2, "XXX=5 赛事没油没票后改为等待60分钟", 15, "left", "38,38,38")
UILabel(2, "XXX=6 赛事没油没票后改为多人刷声望", 15, "left", "38,38,38")
UILabel(2, "远程日志功能,可以访问网址https://yourdomin.cn/api/a9log?udid=" .. ts.system.udid() .. "查看本日脚本日志。", 15, "left", "38,38,38")
UILabel(2, "如果有脚本无法识别的界面,请联系QQ群1028746490群主。如果需要购买脚本授权码也请联系上述QQ群群主。", 20, "left", "38,38,38")
UIShow()
settings = mode .. "|" .. switch .. "|" .. path .. "|" .. gamenum .. "|" .. PVEchooseCar .. "|" .. carplace .. "|" .. backifallstar .. "|" .. PVPatBest .. "|" .. savePower .. "|" .. lowerCar .. "|" .. changeCar .. "|" .. watchAds .. "|" .. timeout_backPVE .. "|" .. skipcar .. "|" .. timeout_parallelRead .. "|" .. email
end
function startGame()
log4l("脚本开始")
toast("脚本开始", 3)
makeGameFront()
ts.httpsGet(apiUrl .. "a9control?udid=" .. ts.system.udid() .. "&command=1", {}, {})
--将脚本状态置为运行
end
function snap()
--截图被存在了userPath().."/res/"下
if width == 0 and height == 0 then
checkScreenSize()
end
pngname = os.date("%Y%m%d%H%M%S_") .. tostring(width) .. "x" .. tostring(height) .. ".png"
snapshot(pngname, 0, 0, height - 1, width - 1)
return pngname
end
function upload(filename)
status = ts.ftp.connect("yourip", "asphalt9", "asphalt9123")
if status then
--上传本地 res 文件夹下的 filename 文件到服务器
upStatus = ts.ftp.upload(root .. filename, "/home/ftp1/" .. tostring(width) .. "x" .. tostring(height) .. "/" .. filename, 0)
else
--toast("连接失败", 0)
end
ts.ftp.close() --操作完成后,断开 FTP 服务器连接
end
function keypress(key)
keyDown(key)
keyUp(key)
end
function uploadSnap()
filename = snap()
upload(filename)
delFile(root .. filename)
end
function restartApp()
uploadSnap()
log4l("游戏重启")
closeApp(gameBid) --关闭游戏
mSleep(5000)
runApp(gameBid) --打开游戏
mSleep(5000)
restartTimes = restartTimes + 1
noAds = 0
end
function wait_when_Parallel_read_detected()
if receive_starting_command == false then
log4l("账号被顶,等待" .. tostring(timeout_parallelRead) .. "分钟")
toast("账号被顶", 1)
mSleep(1000)
toast("等待" .. tostring(timeout_parallelRead) .. "分钟", 1)
stop = wait_time(timeout_parallelRead) --stop==-2停止 stop==-1正常
toast("等待完成", 1)
return stop
end
return -1
end
function wait_time(minutes)
if minutes >= 5 then
closeApp(gameBid)
end
--minutes是数字型
log4l("等" .. tostring(minutes) .. "分钟", 1)
--循环minutes * 6次,每次等10秒,共minutes * 60秒也就是minutes分钟
for _ = 1, minutes * 6 do
mSleep(10 * 1000) --等10秒
end
--https请求获取运行指令
if getHttpsCommand() == 4 then
return -2
else
log4l(tostring(minutes) .. "分钟到", 1)
makeGameFront()
return -1
end
end
function back()
--[[
if model == "SE" then
tap(30, 30)
elseif model == "i68" then
tap(30, 30)
end
]]--
tap(30, 30)
mSleep(2000)
end
function checkTimeOut()
if time ~= -1 then
if (os.time() - time >= timeout_backPVE * 60) then
toast("时间到", 1)
mode = supermode
backHome()
else
--toast(tostring(timeout-(os.time()-time)/60 -((timeout-(os.time()-time)/60)%0.01)).."分钟后返回",1);
--mSleep(1000);
end
end
end
function recordPVPnPVE()
if mode == "多人刷声望" or mode == "多人刷包" then
PVPwithoutPack = PVPwithoutPack + 1
PVPTimes = PVPTimes + 1
log4l("完成" .. tostring(PVPTimes) .. "局多人")
elseif mode == "赛事模式" then
PVETimes = PVETimes + 1
log4l("🚗 完成" .. tostring(PVETimes) .. "局赛事")
end
end
function actAfterNoFuelNTicket()
time = os.time() --记录当前时间
if switch == "多人刷声望" or switch == "多人刷包" then
toast(tostring(timeout_backPVE) .. "分钟后返回", 1)
mode = switch
mSleep(200)
backHome()
return -1
elseif switch == "等30分钟" or switch == "等60分钟" then
changecar = false
if switch == "等30分钟" then
return wait_time(30)
elseif switch == "等60分钟" then
return wait_time(60)
end
return -1
end
end
function watchAd()
beginGame()
mSleep(2000)
if model == "SE" then
tap(731, 427)
elseif model == "i68" then
tap(862, 509)
end
mSleep(3000)
haveAds = checkPlace()
if haveAds == 34 then
worker(haveAds)
noAds = noAds + 1
return -2
end
noAds = 0
if watchAds == "开(有20倍广告加速)" then
mSleep(10000)
elseif watchAds == "开(没有广告加速)" then
mSleep(35000)
end
return -1
end
---通用处理函数[区分设备型号]---
function backHome()
if model == "SE" then
if (isColor(1110, 14, 0xf8f9fb, 85) and isColor(1096, 22, 0xe7ebef, 85) and isColor(1122, 22, 0xe7eaf0, 85) and isColor(1097, 34, 0xc7d1dc, 85) and isColor(1120, 37, 0xc2cbd7, 85) and isColor(1110, 36, 0x13243e, 85)) then
tap(1100, 20) --返回大厅
else
back()
end
elseif model == "i68" then
tap(1300, 30) --返回大厅
end
mSleep(3000)
if checkPlace() ~= 0 then
toast("有内鬼,停止交易", 1)
return -1
end
return 0
end
function getStage()
if model == "SE" then
SE_X, SE_Y = 355, 305
if isColor(SE_X, SE_Y, 0xf1cb30, 85) then
stage = 2 --黄金段位
elseif isColor(SE_X, SE_Y, 0x96b2d4, 85) then
stage = 1 --白银段位
elseif isColor(SE_X, SE_Y, 0xd88560, 85) then
stage = 0 --青铜段位
elseif isColor(SE_X, SE_Y, 0x9365f8, 85) then
stage = 3 --白金段位
elseif isColor(SE_X, SE_Y, 0xf5e2a4, 85) then
stage = 4 --传奇段位
else
stage = -2 --没有段位
end
elseif model == "i68" then
--Undone
i86_X, i86_Y = 430, 355
if isColor(i86_X, i86_Y, 0xf1cb30, 85) then
stage = 2 --黄金段位
elseif isColor(i86_X, i86_Y, 0x96b3d3, 85) then
stage = 1 --白银段位
elseif isColor(i86_X, i86_Y, 0xd88560, 85) then
stage = 0 --青铜段位
elseif isColor(i86_X, i86_Y, 0x9365f8, 85) then
stage = 3 --白金段位
elseif isColor(i86_X, i86_Y, 0xf5e2a4, 85) then
stage = 4 --传奇段位
else
stage = -2 --没有段位
end
end
end
function chooseCarStage()
virtalStage = 0
if lowerCar == "开" then
virtalStage = stage - 1
else
virtalStage = stage
end
baseList = { SE = { 760, 830, 900, 975, 975 }, i68 = { 900, 980, 1060, 1140, 1140 } }
offset = { SE = 70, i68 = 80 }
if virtalStage <= 0 then
virtalStage = 1
end
--TODO:如果是传奇段位,就选三菱
tap(baseList[model][virtalStage + 1] + chooseHighStageCarClass * offset[model], 100)
end
function lowPower()
t = batteryStatus()
--没在充电 电量少于20 停止脚本
return t.charging == 0 and tonumber(t.level) <= 20
end
function toCarbarn()
if PVPchooseCar == true then
getStage()
if stage == 4 and PVPatBest == "否" then
if supermode == "多人刷声望" then
log4l("传奇段位不跑多人")
toast("脚本停止", 1)
return -1
--传奇段位且不在传奇刷多人并且主模式是赛事模式时
elseif supermode == "赛事模式" then
log4l("传奇段位不跑多人,脚本改为赛事模式,等30分钟")
mode = "赛事模式" --将现在的模式改为赛事模式
switch = "等30分钟" --赛事没油改为等30分钟
return 0
end
end
end
if model == "SE" then
tap(720, 570) --进入车库
elseif model == "i68" then
tap(845, 670) --进入车库
end
return 1 --可以进入车库选车并开始PVP
end
function chooseGame()
if model == "SE" then
if gamenum <= 7 then
tap(145 + 165 * (gamenum - 1), 500)
mSleep(1000)
tap(145 + 165 * (gamenum - 1), 500)
else
for _ = 1, gamenum - 7, 1 do
moveTo(610, 500, 483, 500, 20)
mSleep(500)
end
tap(145 + 165 * 6, 500)
mSleep(1000)
tap(145 + 165 * 6, 500)
end
elseif model == "i68" then
if gamenum == 1 then
tap(170, 570)
mSleep(1000)
tap(170, 590)
end
if gamenum > 1 and gamenum <= 6 then
tap(372 + 194 * (gamenum - 2), 570)
mSleep(1000)
tap(372 + 194 * (gamenum - 2), 570)
else
for _ = 0, gamenum - 7, 1 do
moveTo(1250, 500, 1095, 500, 20)
mSleep(500)
end
tap(1300, 570)
mSleep(1000)
tap(1300, 570)
end
end
mSleep(2000)
return -1
end
function checkAndGetPackage()
nomorepack = false
if model == "SE" then
if (isColor(531, 99, 0xfdfff6, 90) and isColor(567, 108, 0xfcfff4, 90) and isColor(615, 109, 0xfcfff5, 90) and isColor(736, 539, 0xff0054, 90)) then
toast("领取多人包", 1)
log4l("🎁 开多人包")
mSleep(700)
tap(570, 470)
mSleep(2000)
tap(500, 600)
mSleep(2000)
tap(1030, 590)
mSleep(10000)
packWithoutRestore = packWithoutRestore + 1
PVPwithoutPack = 0
end
--VIP用户多人包可补充界面为灰色
VIPrestoreButtonDisabled = (isColor(86, 452, 0x010f17, 90) and isColor(134, 452, 0x05121a, 90) and isColor(175, 454, 0x09161e, 90) and isColor(205, 450, 0x06121b, 90) and isColor(199, 467, 0x051219, 90) and isColor(157, 467, 0x010f15, 90) and isColor(123, 466, 0x07141c, 90) and isColor(92, 466, 0x011018, 90) and isColor(96, 478, 0x021019, 90) and isColor(220, 479, 0x09161f, 90))
VIPcanRestore = (isColor(113, 498, 0xdce1e4, 90) and isColor(113, 504, 0xa9b7be, 90) and isColor(105, 504, 0xebeef0, 90) and isColor(105, 501, 0xf7f9f9, 90) and isColor(124, 498, 0xd0d7dc, 90) and isColor(124, 503, 0xd0d7dc, 90) and isColor(134, 503, 0xfefefe, 90) and isColor(137, 503, 0xfafbfb, 90) and isColor(137, 507, 0xebeef0, 90)) and not VIPrestoreButtonDisabled
poorrestoreButtonDisabled = true --TODO:普通用户多人包可补充界面为灰色
poorcanRestore = (isColor(120, 500, 0xfcfdfd, 90) and isColor(123, 500, 0xfcfdfd, 90) and isColor(128, 500, 0xffffff, 90) and isColor(128, 506, 0xdce2e5, 90) and isColor(125, 506, 0xafbdc3, 90) and isColor(143, 506, 0xf2f4f5, 90) and isColor(147, 505, 0xedf0f2, 90) and isColor(151, 500, 0xe9edee, 90) and isColor(154, 511, 0xfafbfa, 90)) and not poorrestoreButtonDisabled
canRestore = VIPcanRestore or poorcanRestore
if canRestore then
if tonumber(os.date("%H")) ~= 7 then
log4l("补充多人包")
packWithoutRestore = 0
tap(153, 462)
mSleep(1000)
else
log4l("可补充多人包,早7点不补充")
end
return 1
end
--[[if VIPrestoreButtonDisabled or poorrestoreButtonDisabled then
nomorepack = true
end]]--
if tonumber(os.date("%H")) ~= 7 then
tap(153, 462) --尝试补充多人包
end
elseif model == "i68" then
tap(668, 576)
mSleep(2000)
place = checkPlace()
if place == 7 then
log4l("🎁 开多人包")
receivePrizeAtGame()
PVPwithoutPack = 0
mSleep(10000)
elseif place == 1 then
back()
end
if tonumber(os.date("%H")) ~= 7 then
tap(176, 545) --尝试补充多人包
end
end
--现在位于大厅,页面在多人界面
if shouldStop(nomorepack) then
return -2
else
return 1
end
end
function unlockedDevice()
flag = deviceIsLock()
if flag == 1 then
unlockDevice();
end
end
function checkShouldSwitchAccount()
a9getCommandcode, a9getCommandheader_resp, a9getCommandbody_resp = ts.httpsGet(apiUrl .. "a9switchAccount?udid=" .. ts.system.udid(), {}, {})
if a9getCommandcode == 200 then
return a9getCommandbody_resp
else
return "null"
end
end
function switchAccount(account, passwd)
accountnum = account
account = splitStr(account) --拿到账号
passwd = splitStr(passwd) --拿到密码
backHome()
tap(1100, 20) --按下设置
mSleep(2000)
tap(655, 300)--按下退出
mSleep(2000)
tap(390, 425)--按下确定
mSleep(5000)
tap(570, 520)--按下开始
mSleep(4000)
for _ = 1, 10 do
tap(1030, 40)--按右上角切换账号
mSleep(500)
end
tap(540, 205)--按下账号输入框弹出键盘
mSleep(2000)
tap(723, 63)--按下删除清清除当前账号密码
mSleep(2000)
--输入账号
keypress('1')--第一次keypress会失效
mSleep(500)
for i = 1, #account do
keypress(account[i])
end
mSleep(1000)
tap(381, 157) --按下密码输入框
mSleep(1000)
--输入密码
for i = 1, #passwd do
keypress(passwd[i])
end
tap(580, 257) --点击登陆
log4l("登陆账号" .. accountnum)
mSleep(10000)
end
function shouldStop(nomorepack)
--开完最后一个包可能不会立刻停止,因为12个奖杯只需要少于12局即可完成,代码中写12是为稳定起见 //针对SE:连续开4个包但没补充应该停止
if (mode == "多人刷包" and PVPwithoutPack >= 12) or (model == "SE" and mode == "多人刷包" and (packWithoutRestore >= 4 or nomorepack or PVPwithoutPack >= 12)) then
log4l("🈚 " .. accountnum .. "没有多人包可刷")
--将账号accountnum在数据库中状态改为刷包关闭
ts.httpsGet(apiUrl .. "a9accountDone?udid=" .. ts.system.udid() .. "&account=" .. nowaccount, {}, {})
if supermode == "赛事模式" and switch == "多人刷包" then
log4l("赛事没油没票改为等30分钟")
switch = "等30分钟"
mode = supermode
return false
end
if switchaccountfun then
--查看是否有需要刷包的账号
nowaccount = checkShouldSwitchAccount()
if nowaccount ~= "null" then
-- 拿到账号密码
data = strSplit(nowaccount, '_', 1)
switchAccount(data[1], data[2]) --切换账号
PVPwithoutPack, packWithoutRestore = 0, 0 --初始化刷包数据
return false
end
end
--没有账号可以切换,脚本应该停止
return true
elseif savePower == "开" and lowPower() then
log4l("电量低,脚本停止")
return true
elseif getHttpsCommand() == 4 then
return true
end
return false
end
function receivePrizeFromGL()
log4l("🎁 领取来自gameloft的礼物")
if model == "SE" then
tap(1015, 582)
mSleep(5000)
tap(569, 582)
mSleep(2000)
tap(1015, 582)
elseif model == "i68" then
tap(1015, 582)
mSleep(5000)
tap(569, 582)
mSleep(2000)
tap(1015, 582)
end
mSleep(2000)
end
function chooseCar()
mSleep(2500)
if PVPchooseCar then
chooseCarStage()
mSleep(1500)
chooseClassCar()
mSleep(3000)
if not switchToSuitableCar() then
return false
end
end
if PVPchooseCar == false then
if carCanUse() == false and watchAds ~= "关" then
if watchAd() == -1 then
if model == "SE" then
tap(1077, 83) --关闭广告
elseif model == "i68" then
tap(1276, 83) --关闭广告