-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHсBOT.lua
302 lines (279 loc) · 10.4 KB
/
HсBOT.lua
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
-- Îãðîìíîå ñïàñèáî: exportaccountdata, quesada, ÷îêî ìàìè (ðàçáàíüòå åãî ïæ)
require("addon")
local sampev = require("samp.events")
local inicfg = require('inicfg')
local cfg = inicfg.load(nil, "hcbot")
local hcbot_start = false
local packets = 0
function onRunCommand(cmd)
if cmd:find("^!key %d+$") then -- êîìàíäà äëÿ ýìóëÿöèè íàæàòèé êíîïîê
sendKey(tonumber(cmd:match("%d+")))
return false
end
if cmd == "!hcbot" then -- äëÿ çàïóñêà áîòà
hcbot_start = not hcbot_start
if hcbot_start then printm("HcBot íà÷àë ñâîþ ðàáîòó.") else printm("HcBot çàêîí÷èë ñâîþ ðàáîòó.") end
return false
end
if cmd:find("^!hcbot offatspawn") then -- âûêëþ÷àòü ëè êóðä ïðè ñïàâíå
cfg.settings.coord_ofatspawn = not cfg.settings.coord_ofatspawn
if cfg.settings.coord_ofatspawn then
printm("Åñëè çàñïàâíÿò - êîîðäìàñòåð îñòàíîâèòñÿ.")
else
printm("Åñëè çàñïàâíÿò - êîîðäìàñòåð ÍÅ îñòàíîâèòñÿ.")
end
return false
end
if cmd:find("^!hcbot timestep_onfoot %d+$") then -- íàñòðîéêà çàäåðæêè òï ñ íîã
cfg.settings.timestep_onfoot = tonumber(cmd:match("%d+"))
printm("Çàäåðæêà ìåæäó òåëåïîðòîì: " .. cfg.settings.timestep_onfoot .. " ìñ.")
return false
end
if cmd:find("^!hcbot step_onfoot %d+$") then -- íàñòðîéêà øàãà òï ñ íîã
cfg.settings.step_onfoot = tonumber(cmd:match("%d+"))
printm("Øàã òåëåïîðòà: " .. cfg.settings.step_onfoot .. " ìåòðîâ.")
return false
end
if cmd:find("^!hcbot timestep_incar %d+$") then -- íàñòðîéêà çàäåðæêè òï ñ êàðà
cfg.settings.timestep_incar = tonumber(cmd:match("%d+"))
printm("Çàäåðæêà ìåæäó òåëåïîðòîì: " .. cfg.settings.timestep_incar .. " ìñ.")
return false
end
if cmd:find("^!hcbot step_incar %d+$") then -- íàñòðîéêà øàãà òï ñ êàðà
cfg.settings.step_incar = tonumber(cmd:match("%d+"))
printm("Øàã òåëåïîðòà: " .. cfg.settings.step_incar .. " ìåòðîâ.")
return false
end
if cmd:find("^!hcbot visota %d+$") then -- íàñòðîéêà øàãà òï ñ êàðà
cfg.settings.visota = tonumber(cmd:match("%d+"))
printm("Íà ñêîëüêî ìåòðîâ òåïàòñÿ íèæå: " .. cfg.settings.visota .. " ì.")
return false
end
if cmd:find("^!hcbot info") then -- äëÿ âûâîäà èíôîðìàöèè
printm("================ Íàñòðîéêè ñ íîã ===============")
printm("Çàäåðæêà ìåæäó òåëåïîðòîì: " .. cfg.settings.timestep_onfoot .. " ìñ.")
printm("Øàã òåëåïîðòà: " .. cfg.settings.step_onfoot .. " ìåòðîâ.")
printm("================ Íàñòðîéêè ñ ìàøèíû ===============")
printm("Çàäåðæêà ìåæäó òåëåïîðòîì: " .. cfg.settings.timestep_incar .. " ìñ.")
printm("Øàã òåëåïîðòà: " .. cfg.settings.step_incar .. " ìåòðîâ.")
printm("================ Ïðî÷èå íàñòðîéêè ==============")
printm("Íà ñêîëüêî ìåòðîâ òåïàòñÿ íèæå: " .. cfg.settings.visota .. " ì.")
printm("Áîò â ìàøèíå: " .. tostring(getBotVehicle()).." (åñëè 0 - íå â ìàøèíå, îñòàëüíîå ýòî èä ìàøèíû)")
printm("Áîò âêëþ÷åí: " .. tostring(hcbot_start))
printm("!hcbot save - ñîõðàíèòü íàñòðîéêè")
printm(" * https://www.blast.hk/members/421795/")
return false
end
if cmd:find("^!hcbot save") then -- äëÿ ñîõðàíåíèÿ íàñòðîåê
inicfg.save(cfg, 'hcbot.ini')
printm("Íàñòðîéêè óñïåøíî ñîõðàíåíû!")
return false
end
if cmd:find("^!hcbot repare_old") then -- äëÿ âîçâðàùåíèÿ íàñòðîåê â ïðåæíåå ñîñòîÿíèå
cfg.settings.coord_ofatspawn = "true"
cfg.settings.timestep_onfoot = "40"
cfg.settings.step_onfoot = "2"
cfg.settings.timestep_incar = "50"
cfg.settings.step_incar = "7"
cfg.settings.visota = "10"
inicfg.save(cfg, 'hcbot.ini')
printm("Íàñòðîéêè óñïåøíî âîññòàíîâëåíû!")
return false
end
if cmd:find("^!hcbot help") then -- äëÿ âûâîäà êîìàíä
printm("!hcbot - âêëþ÷èòü ÷åêïîèíò áîòà")
printm("!key àéäè - åìóëèðîâàòü íàæàòèå êíîïêè")
printm("!hcbot save - ñîõðàíèòü íàñòðîéêè")
printm("!hcbot repare_old - âîññòàíîâèòü íàñòðîéêè êàê áûëè")
printm("!hcbot offatspawn - âûêëþ÷àòü ëè òï åñëè âî âðåìÿ òï ñïàâíÿò")
printm("!hcbot timestep_onfoot ìñ - íàñòðîéêà çàäåðæêè ïåðåä òï ñ íîã")
printm("!hcbot step_onfoot ìåòðû - íàñòðîéêà øàãà òï ñ íîã")
printm("!hcbot timestep_incar ìñ - íàñòðîéêà çàäåðæêè ïåðåä òï ñ ìàøèíû")
printm("!hcbot step_incar ìåòðû - íàñòðîéêà øàãà òï ñ ìàøèíû")
printm("!hcbot info - âûâåñòè èíôîðìàöèþ îá íàñòðîéêàõ")
printm("!getcars - âûâåñòè ìàøèíû êîòîðûå íàõîäÿòñÿ â çîíå ñòðèìà")
printm("!sest idcar x_car y_car z_car - ñåñòü â ìàøèíó")
printm(" * x_car, y_car, z_car - êîîðäèíàòû ìàøèíû, idcar - èä ìàøèíû")
printm("!musor - âêë/âûêë îòîáðàæåíèÿ ìóñîðíûõ ñîîáùåíèé â ÷àò")
printm("!hcbot help - âûâåñòè äàííîå ñîîáùåíèå")
printm(" * https://www.blast.hk/members/421795/")
return false
end
if cmd == "!getcars" then -- äëÿ âûâîäà ìàøèí â çîíå ñòðèìà
cars = getAllVehicles()
for k, v in pairs(cars) do
x, y, z = getBotPosition()
distance = getDistanceBetweenCoords(x, y, z, v.position.x, v.position.y, v.position.z)
print(v.name .. "["..k.."]" .. " | Coord: X: "..math.floor(v.position.x).." Y: "..math.floor(v.position.y).." Z: "..math.floor(v.position.z) .. " | Çàêðûò: "..tostring(v.locked).." | Äèñòàíöèÿ: "..math.floor(distance).." ì.")
end
return false
end
if cmd:find("^!sest (.*)") then -- ÷òîáû ñåñòü â ìàøèíó (èñïîëüçîâàíèå !sest àéäè_ìàøèíû êîîðäèíàòà_ìàøèíû_X êîîðäèíàòà_ìàøèíû_Y êîîðäèíàòà_ìàøèíû_Z)
if getBotVehicle() == 0 then
sesti(cmd:match("(.*)"))
else
printm("Áîò íàõîäèòñÿ â ìàøèíå.")
end
return false
end
if cmd == "!musor" then -- îòîáðàæàòü ëè ìóñîð â ÷àòå
cfg.settings.chat_musor = not cfg.settings.chat_musor
if cfg.settings.chat_musor then printm("Îòîáðàæåíèå ìóñîðà â ÷àòå - âêëþ÷åíî.") else printm("Îòîáðàæåíèå ìóñîðà â ÷àòå - âûêëþ÷åíî.") end
return false
end
end
function onPrintLog(text) -- õóê íà òåêñò
if cfg.settings.chat_musor then
if text:find("gtasounds") or text:find("COORD") then --or text:find("")
return false
end
end
end
function sesti(param) -- êîìàíäà ÷òîáû ïðèëèòåòü è ñåñòü â ìàïàøèíó íà âîäèòåëüñêîå
local id, xs, ys, zs = string.match(param, '(%d+)%s(.*)%s(.*)%s(.*)')
xs = tonumber(xs)
ys = tonumber(ys)
zs = tonumber(zs)
idd = tonumber(id)
mashinka = 1
coordStart(xs, ys, zs, cfg.settings.timestep_onfoot, cfg.settings.step_onfoot, cfg.settings.coord_ofatspawn)
end
function onCoordStop() -- åñëè êóðäìàñòåð çêîí÷èë ðàáîòó
newTask(function()
if mashinka == 1 then
mashinka = 0
sendVehicleEnter(idd, 0) -- ñåñòü â ìàøèíó
wait(1000)
setBotVehicle(idd, 0) -- ñåñòü â ìàøèíó ÷òîá òî÷íî
print("Ñåëè â ìàøèíó: "..idd)
end
printm("Óñïåøíî ïðèëåòåëè.")
if getBotVehicle() ~= 0 then
wait(2500)
x, y, z = getBotPosition()
setBotPosition(x, y, z-cfg.settings.visota+1)
end
end)
end
function sampev.onSendVehicleSync(data) -- åñëè èíêàð îòïðàâèò sync
if hcbot_start then
data.moveSpeed.x = 0.5
data.moveSpeed.y = 0.5
data.moveSpeed.z = 1.0
end
end
function sampev.onSendPlayerSync(data) -- åñëè îíôóò îòïðàâèò sync
if hcbot_start then
data.moveSpeed.x = 0.5
data.moveSpeed.y = 0.5
data.moveSpeed.z = 1.0
end
end
function getDistanceBetweenCoords(x, y, z, px, py, pz) -- äëÿ óçíàâàíèÿ äèñòàíöèè ìåæäó òîáîé è êîîðäèàíàòîé
local distance = math.sqrt((px - x)^2 + (py - y)^2 + (pz - z)^2)
return distance
end
function onCoordStart() -- åñëè êóðäìàñòåð íà÷àë ðàáîòó
if getBotVehicle() ~= 0 then
x, y, z = getBotPosition()
setBotPosition(x, y, z-cfg.settings.visota)
end
printm("Êóðäìàñòåð íà÷àë ñâîþ ðàáîòó.")
end
newTask(function()
while true do wait(0)
if isCoordActive() then
wait(100)
if getBotVehicle() == 0 then -- 0 - íå â ìàøèíå
packets = packets + 1
if packets >= 7 then
packets = 0
sleep(239)
end
else
packets = packets + 1
if packets >= 7 then
packets = 0
sleep(400)
end
end
end
end
end)
function sampev.onSetRaceCheckpoint(type, position, nextPosition, size) -- åñëè îòïðàâèëè ÷åêïîèíò
if hcbot_start then
x, y, z = getBotPosition()
distance = getDistanceBetweenCoords(x, y, z, position.x, position.y, position.z)
printm("Ïîéìàëè ÷åêïîèíò: "..math.floor(position.x)..", "..math.floor(position.y)..", "..math.floor(position.z).." | Äèñòàíöèÿ: "..math.floor(distance).." m.")
if getBotVehicle() == 0 then -- 0 - íå â ìàøèíå
coordStart(position.x, position.y, position.z, cfg.settings.timestep_onfoot, cfg.settings.step_onfoot, cfg.settings.coord_ofatspawn)
else
coordStart(position.x, position.y, position.z, cfg.settings.timestep_incar, cfg.settings.step_incar, cfg.settings.coord_ofatspawn)
end
end
end
-- âíèçó âñ¸ ÷òî íóæíî äëÿ àâòîðèçàöèè ëèáî ðåãèñòðàöèè àêêàóíòà
function sampev.onShowDialog(id, style, title, btn1, btn2, text)
if title:find('Ïàðîëü') then
sendDialogResponse(id, 1, 0, cfg.settings.password)
return false
end
if title:find('Âûáåðèòå âàø ïîë') then
sendDialogResponse(id, 1, 0, "")
return false
end
if title:find('Âûáåðèòå öâåò êîæè') then
sendDialogResponse(id, 1, 0, "")
return false
end
if title:find('âû î íàñ óçíàëè?') then
sendDialogResponse(id, 1, 1, "")
return false
end
if title:find('Ââåäèòå íèê ïðèãëàñèâøåãî?') then
sendDialogResponse(id, 1, 0, cfg.settings.referal)
return false
end
if title:find('Äîïîëíèòåëüíàÿ') then
sendDialogResponse(id, 0, 0, "")
return false
end
if title:find('Àâòîðèçàöèÿ') then
sendDialogResponse(id, 1, 0, cfg.settings.password)
return false
end
end
function sampev.onShowTextDraw(id, data) -- ÷òî-áû âûáðàëî ñêèí íîðìàëüíî
if id == 419 then
newTask(function()
wait(1000)
sendClickTextdraw(id)
end)
end
end
function onSendRPC(id, bs)
if id == 128 then -- ÷òîáû ïðèíÿòü ðåêâåñò êëàññ
return true
end
end
-- äëÿ ýìóëÿöèè íàæàòèé íà êíîïêè è òä
function sampev.onSendPlayerSync(data)
if key then
data.keysData = key
key = nil
end
end
function sendKey(id)
printm("Îòïðàâèë êíîïêó: "..id)
key = id
updateSync()
end
-- âíèçó íå íóæíîå (äëÿ ðàáîòû ñêðèïòà íóæíîå)
function printm(text)
print("[HcBOT]: "..text)
end
function onLoad()
printm("Óñïåøíî çàãðóæåí! By Haymiritch")
printm(" * https://www.blast.hk/members/421795/")
printm(" * Êîìàíäû: !hcbot help")
end