- 86
- 5
- Версия MoonLoader
- .026-beta
Сделал бота, но при вводе команды активации ничего не происходит
сам скрипт:
сам скрипт:
Код:
script_name("Shaxta bot by Kalgan")
script_authors("Kalgan_Kalganov")
script_description("Бот создан для своих")
script_version("0.1")
script_dependencies("CLEO")
---------------------------------------------------------------------------
require "lib.moonloader"
---------------------------------------------------------------------------
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
sampRegisterChatCommand("botstart", cmd_bot)
shaxta == 0
local saveX = {}
local saveY = {}
local saveZ = {}
local sampev = require "lib.samp.events"
while true do
wait(0)
if isPlayerPlaying(playerHandle) and enabled then
---------------------------------------------------------------------------
local posX, posY, posZ = GetCoordinates()
local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
if mfind then BeginToPoint(mposX, mposY, mposZ, 1.000000, -255, false) end
wait(10000)
BeginToPoint(-1898.900024, 1247.760010, 1214.839966, 1.000000, -255, false)
wait(1020)
BeginToPoint(-1925.949951, 1247.910034, 1216.079956, 30.000000, -255, false)
wait(510)
local posX, posY, posZ = GetCoordinates()
local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
if mfind then BeginToPoint(mposX, mposY, mposZ, 30.000000, -255, false) end
wait(510)
BeginToPoint(-1964.180054, 1248.329956, 1216.160034, 30.000000, -255, false)
wait(510)
BeginToPoint(-1912.709961, 1248.219971, 1216.770020, 30.000000, -255, false)
wait(510)
end
if shaxta == 0 then main() end
if sampev.onServerMessage(color, У вас сломалась кирка! Для продолжения работы необходимо купить новую!)
then shaxta == 1
else
shaxta == 0 end
if shaxta == 1 then Kirka() end
-----------------------------------------------------------------------
end
end
function Kirka()
BeginToPoint(-1913.66, 1248.329956, 1248.18, 1216.58, -255, false)
wait(510)
local posX, posY, posZ = GetCoordinates()
local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
if mfind then BeginToPoint(mposX, mposY, mposZ, 1.000000, -255, false) end
wait(510)
sampSendDialogResponse(9440, 1, 0, Лифт шахты )
wait (510)
BeginToPoint(-1894.32, 1248.219971, -1645.16, 21.77, -255, false)
wait(510)
BeginToPoint(-1870.060059, -1636.270020, 21.879999, -255, false)
local posX, posY, posZ = GetCoordinates()
local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
if mfind then BeginToPoint(mposX, mposY, mposZ, 30.000000, -255, false) end
wait(510)
sampSendDialogResponse(9441, 1, 1, Покупка кирки )
wait(510)
sampCloseCurrentDialogWithButton(1)
wait(510)
BeginToPoint(-1873.93, -1639.25, 21.88, -255, false)
wait(510)
local posX, posY, posZ = GetCoordinates()
local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 150.000000, false)
if mfind then BeginToPoint(mposX, mposY, mposZ, 1.000000, -255, false) end
wait(510)
sampSendDialogResponse(9440, 1, 4, Лифт шахты )
wait(510)
BeginToPoint(-1913.66, 1248.329956, 1248.18, 1216.58, -255, false)
wait(510)
if BeginToPoint(-1913.66, 1248.329956, 1248.18, 1216.58, -255, false)
then shaxta == 0 end
end
--------------------------- STANDART FUNCTIONS ---------------------------
function BeginToPoint(x, y, z, radius, move_code, isSprint)
repeat
local posX, posY, posZ = GetCoordinates()
SetAngle(x, y, z)
MovePlayer(move_code, isSprint)
local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
wait(0)
until not enabled or dist < radius
end
function MovePlayer(move_code, isSprint)
setGameKeyState(1, move_code)
--[[255 - обычный бег назад
-255 - обычный бег вперед
65535 - идти шагом вперед
-65535 - идти шагом назад]]
if isSprint then setGameKeyState(16, 255) end
end
function SetAngle(x, y, z)
local posX, posY, posZ = GetCoordinates()
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 GetCoordinates()
if isCharInAnyCar(playerPed) then
local car = storeCarCharIsInNoSave(playerPed)
return getCarCoordinates(car)
else
return getCharCoordinates(playerPed)
end
end
function cmd_bot(param)
enabled = not enabled
if enabled then
sampAddChatMessage(string.format("[%s]: Активирован", thisScript().name), 0x40FF40)
else
sampAddChatMessage(string.format("[%s]: Деактивирован", thisScript().name), 0xFF4040)
end
end
-- Teleport from ClickWarp (by FYP)
function teleportPlayer(x, y, z)
if isCharInAnyCar(playerPed) then
setCharCoordinates(playerPed, x, y, z)
end
setCharCoordinatesDontResetAnim(playerPed, x, y, z)
end
function setCharCoordinatesDontResetAnim(char, x, y, z)
if doesCharExist(char) then
local ptr = getCharPointer(char)
setEntityCoordinates(ptr, x, y, z)
end
end
function setEntityCoordinates(entityPtr, x, y, z)
if entityPtr ~= 0 then
local matrixPtr = readMemory(entityPtr + 0x14, 4, false)
if matrixPtr ~= 0 then
local posPtr = matrixPtr + 0x30
writeMemory(posPtr + 0, 4, representFloatAsInt(x), false) --X
writeMemory(posPtr + 4, 4, representFloatAsInt(y), false) --Y
writeMemory(posPtr + 8, 4, representFloatAsInt(z), false) --Z
end
end
end
-- End Teleport code
--------------------------- ADDITIONAL FUNCTIONS ---------------------------
function SearchMarker(posX, posY, posZ, radius, isRace)
local ret_posX = 0.0
local ret_posY = 0.0
local ret_posZ = 0.0
local isFind = false
for id = 0, 31 do
local MarkerStruct = 0
if isRace then MarkerStruct = 0xC7F168 + id * 56
else MarkerStruct = 0xC7DD88 + id * 160 end
local MarkerPosX = representIntAsFloat(readMemory(MarkerStruct + 0, 4, false))
local MarkerPosY = representIntAsFloat(readMemory(MarkerStruct + 4, 4, false))
local MarkerPosZ = representIntAsFloat(readMemory(MarkerStruct + 8, 4, false))
if MarkerPosX ~= 0.0 or MarkerPosY ~= 0.0 or MarkerPosZ ~= 0.0 then
if getDistanceBetweenCoords3d(MarkerPosX, MarkerPosY, MarkerPosZ, posX, posY, posZ) < radius then
ret_posX = MarkerPosX
ret_posY = MarkerPosY
ret_posZ = MarkerPosZ
isFind = true
radius = getDistanceBetweenCoords3d(MarkerPosX, MarkerPosY, MarkerPosZ, posX, posY, posZ)
end
end
end
return isFind, ret_posX, ret_posY, ret_posZ
end