--Нам понадобится samp.lua для работы с чатом и диалогами
local events = require 'lib.samp.events'
local act = false --Состояние бота(вкл/выкл)
local run = 0 --[[
0 = состояние выключенного скрипта
1 = бег к устройству
2 = бег к столу с деталями
3 = бег к столу сборки
4 = бег к сдаче готовой детали]]
function main()
sampRegisterChatCommand('pobejali',activation)
while true do
wait(100)
if run == 1 then
run = 0
runTo2(2568.2, -1281.5, 1044,0.3, -255, false)
end
if run == 2 then
run = 0
runTo2(2559.5, -1289.5, 1044,0.5,-255, false)
runTo2(2558.99, -1287.22, 1044,0.5,-255, false)
end
if run == 3 then
run = 0
runTo2(2556.71, -1291, 1044,0.5,-255, false)
end
if run == 4 then
run = 0
runTo2(2564.7, -1292.9, 1044,0.5,-255, false)
end
end
wait(-1)
end
function activation()
if act == false then act = true printString('Bot ~g~On',1000) run = 1
elseif act == true then act = false printString('Bot ~g~Off',1000) run = 0 end
end
function events.onShowDialog(did,style,title,btn1,btn2,text)
if did == 41 and act then
sampSendDialogResponse(did,1,-1,'')
return false
end
end
function events.onServerMessage(clr, msg)
if string.find(msg,'Поздравляем.') and string.find(msg,'чтобы взять детали.') then
run = 2
end
---------------------
if string.find(msg,'Вы взяли детали.') then
run = 3
end
if string.find(msg,'Вы собрали запчасть.') then
run = 4
end
---------------------
if string.find(msg,'Запчасть сдана на склад.') then
run = 2
end
if string.find(msg,'Вы сделали бракованную запчасть') then
run = 2
end
if string.find(msg,'На этом столе нет деталей.') then
run = 2
end
if string.find(msg,'Вы уронили запчасть') then
run = 2
end
end
function runTo(x, y, z, radius, isRun)
while true do
local posX, posY, posZ = getCharCoordinates(playerPed)
SetAngle(x, y, z)
wait(0)
local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
MovePlayer(-255, isRun, dist)
if dist < radius then
return
end
end
end
function MovePlayer(move_code, isRun, dis)
setGameKeyState(1, move_code)
if isSprint then
setGameKeyState(16, 255)
end
end
function SetAngle(x, y, z)
local posX, posY, posZ = getCharCoordinates(playerPed)
local pX = x - posX
local pY = y - posY
local zAngle = getHeadingFromVector2d(pX, pY)
if isCharInAnyCar(playerPed) then
local car = storeCarCharIsInNoSave(playerPed)
setCarHeading(car, zAngle)
else
setCharHeading(playerPed, zAngle)
end
restoreCameraJumpcut()
end
function runTo2(x, y, z, radius, isSprint) --новый бег
while true do
wait(0)
if act then
local posX, posY, posZ = getCharCoordinates(playerPed)
--angle
local pX = x - posX
local pY = y - posY
local zAngle = getHeadingFromVector2d(pX, pY)
local ang = getCharHeading(playerPed)
local zz = math.abs(zAngle) - math.abs(ang)
local wp = fix(representIntAsFloat(readMemory(0xB6F248, 4, false)))
local gg = fix(representIntAsFloat(readMemory(0xB6F258, 4, false)))
gg = math.abs(gg)
local betaRun = math.abs(gg-GetAngleBeetweenTwoPoints(x,y))
if wp < 1.0 and wp < -1.0 then wp = 0 end
setCameraPositionUnfixed(wp-0.001, GetAngleBeetweenTwoPoints(x,y))
local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
setGameKeyState(1, -255)
if isSprint then
setGameKeyState(16, 255)
end
if dist < radius then
return
end
end
end
end
function events.onSendAimSync(d)--спизженный фикс
if isActive then
local x = math.random(10, 150)
local y = math.random(10, 150)
local z = math.random(10, 150)
local oldX = d.camFront.x
local oldY = d.camFront.y
local oldZ = d.camFront.z
d.camFront.x = x / 100
d.camFront.y = y / 100
d.camFront.z = z / 100
end
end
function fix(angle) --еще один фикс
while angle > math.pi do
angle = angle - (math.pi*2)
end
while angle < -math.pi do
angle = angle + (math.pi*2)
end
return angle
end
function GetAngleBeetweenTwoPoints(x2,y2) -- нужно зачемта
local x1, y1, z1 = getCharCoordinates(playerPed)
local plus = 0.0
local mode = 1
if x1 < x2 and y1 > y2 then plus = math.pi/2; mode = 2; end
if x1 < x2 and y1 < y2 then plus = math.pi; end
if x1 > x2 and y1 < y2 then plus = math.pi*1.5; mode = 2; end
local lx = x2 - x1
local ly = y2 - y1
lx = math.abs(lx)
ly = math.abs(ly)
if mode == 1 then ly = ly/lx;
else ly = lx/ly; end
ly = math.atan(ly)
ly = ly + plus
return ly
end