Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Сделал я бота для радмира, он правильно идёт к 3d тексту берет ящик идёт к чекпоинту и пишет в чат 1 2 3 с задержкой и жмёт enter но после этого снова повторяет 1 2 3 и больше не идёт 3d тексту, а повторяет 1 2 3 хоть и стоит цикл
Код:
script_name("gruzz")
script_authors("Joshua_Young")
script_description("Бот создан в bot maker")
script_version("0.1")
script_dependencies("CLEO", "SAMP", "SAMPFUNCS")
---------------------------------------------------------------------------
require "lib.moonloader"
require "lib.sampfuncs"
local ffi = require "ffi"
ffi.cdef[[
void keybd_event(int keycode, int scancode, int flags, int extra);
]]
---------------------------------------------------------------------------
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
sampRegisterChatCommand("gruzz", cmd_bot)
local saveX = {}
local saveY = {}
local saveZ = {}
while true do
wait(0)
if isPlayerPlaying(playerHandle) and enabled then
---------------------------------------------------------------------------
local X, Y, Z = GetCoordinates()
local result, text, color, posX, posY, posZ, distance, ignoreWalls, player, vehicle = Search3Dtext(X, Y, Z, 50.000000, "Конвеер")
if result then BeginToPoint(posX, posY, posZ, 1.000000, -255, false) end
wait(1140)
local posX, posY, posZ = GetCoordinates()
local mfind, mposX, mposY, mposZ = SearchMarker(posX, posY, posZ, 50.000000, false)
if mfind then BeginToPoint(mposX, mposY, mposZ, 1.000000, -255, false) end
wait(3020)
sampSendChat("1")
wait(1020)
sampSendChat("2")
wait(1020)
sampSendChat("3")
wait(1020)
EmulateKey(VK_RETURN, true)
wait(20)
EmulateKey(VK_RETURN, false)
---------------------------------------------------------------------------
end
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
function Search3Dtext(x, y, z, radius, patern)
local text = ""
local color = 0
local posX = 0.0
local posY = 0.0
local posZ = 0.0
local distance = 0.0
local ignoreWalls = false
local player = -1
local vehicle = -1
local result = false
for id = 0, 2048 do
if sampIs3dTextDefined(id) then
local text2, color2, posX2, posY2, posZ2, distance2, ignoreWalls2, player2, vehicle2 = sampGet3dTextInfoById(id)
if getDistanceBetweenCoords3d(x, y, z, posX2, posY2, posZ2) < radius then
if string.len(patern) ~= 0 then
if string.match(text2, patern, 0) ~= nil then result = true end
else
result = true
end
if result then
text = text2
color = color2
posX = posX2
posY = posY2
posZ = posZ2
distance = distance2
ignoreWalls = ignoreWalls2
player = player2
vehicle = vehicle2
radius = getDistanceBetweenCoords3d(x, y, z, posX, posY, posZ)
end
end
end
end
return result, text, color, posX, posY, posZ, distance, ignoreWalls, player, vehicle
end
function EmulateKey(key, isDown)
if not isDown then
ffi.C.keybd_event(key, 0, 2, 0)
else
ffi.C.keybd_event(key, 0, 0, 0)
end
end
Последнее редактирование: