SA:MP Mobile Нужен помощь при создании бота лесапинку rodina rp

Макс2003

Новичок
Автор темы
4
0
У меня такая проблема что телепортируется прямо дерево но сдачу не телепортируется он только остаётся она на дереве теперь я первый раз создаю такое бот у меня уже есть более хлоп помогите пожалуйста

У меня всё готовый код только прямо на сдачу дерева не ТП нету все координаты брал но н****

script_name('WallHack+Les')
script_version('4.4')
script_author('Максат edit')
script_description('WallHack + Лес (дерево → фиксированные координаты сдачи) /rendw')

function main()
local font = renderCreateFont("Arial", 8, 0)
local wallhackEnabled = false
local treeModel = -1
local lesEnabled = false
local lastTree = nil
local state = "waitTree"
local choppingTime = 3000 -- 3 сек задержка
local instantMode = false

-- 📌 фиксированные координаты сдачи
local pointX, pointY, pointZ = -2139.8, -1354.0, 48.8

sampRegisterChatCommand("rendw", function(params)
if not params or #params == 0 then
sampAddChatMessage("Используй: /rendw [ID дерева] [fast] | /rendw -2", -1)
return
end

local args = {}
for w in string.gmatch(params, "%S+") do table.insert(args, w) end

if tonumber(args[1]) == -2 then
wallhackEnabled, lesEnabled = false, false
treeModel = -1
state, lastTree = "waitTree", nil
instantMode = false
sampAddChatMessage("WallHack/Лес выключен", -1)
return
end

if tonumber(args[1]) then
treeModel = tonumber(args[1])
lesEnabled = true
wallhackEnabled = true
state, lastTree = "waitTree", nil
instantMode = (args[2] == "fast")
if instantMode then
sampAddChatMessage(("⚡ Лесоруб включён: дерево %d → сдача МОМЕНТАЛЬНО (%.1f, %.1f, %.1f)"):format(treeModel, pointX, pointY, pointZ), -1)
else
sampAddChatMessage(("🌲 Лесоруб включён: дерево %d → сдача с задержкой (%.1f, %.1f, %.1f)"):format(treeModel, pointX, pointY, pointZ), -1)
end
end
end)

while true do
wait(0)

local px, py, pz = getCharCoordinates(PLAYER_PED)
local x10, y10 = convert3DCoordsToScreen(px, py, pz)

-- WallHack (только для деревьев)
if wallhackEnabled then
for _, v in pairs(getAllObjects()) do
if isObjectOnScreen(v) then
local model = getObjectModel(v)
if (treeModel ~= -1 and model == treeModel) then
local _, x, y, z = getObjectCoordinates(v)
local x1, y1 = convert3DCoordsToScreen(x, y, z)
local distance = getDistanceBetweenCoords3d(x, y, z, px, py, pz)
renderFontDrawText(
font,
("model: %d | dist: %.1fm"):format(model, distance),
x1, y1,
0xFFFF00FF
)
renderDrawLine(x10, y10, x1, y1, 1.0, 0xFFFF00FF)
end
end
end
end

-- Лесоруб
if lesEnabled then
if state == "waitTree" then
local nearestTree, distTree = nil, 99999
for _, v in pairs(getAllObjects()) do
if getObjectModel(v) == treeModel then
local _, x, y, z = getObjectCoordinates(v)
local dist = getDistanceBetweenCoords3d(x, y, z, px, py, pz)
if dist < distTree then
distTree = dist
nearestTree = {handle = v, x = x, y = y, z = z}
end
end
end

if nearestTree and nearestTree.handle ~= lastTree then
setCharCoordinates(PLAYER_PED, nearestTree.x, nearestTree.y, nearestTree.z + 1.0)
sampAddChatMessage(("🌲 Телепорт к дереву %.1f, %.1f, %.1f"):format(nearestTree.x, nearestTree.y, nearestTree.z), -1)
lastTree = nearestTree.handle
end

if lastTree and not doesObjectExist(lastTree) then
if instantMode then
state = "toPoint"
else
state = "chopping"
sampAddChatMessage("🔨 Рублю дерево...", -1)
lua_thread.create(function()
wait(choppingTime)
state = "toPoint"
end)
end
end

elseif state == "toPoint" then
setCharCoordinates(PLAYER_PED, pointX, pointY, pointZ + 1.0)
sampAddChatMessage(("📦 Сдача: %.1f, %.1f, %.1f"):format(pointX, pointY, pointZ), -1)
state = "waitTree"
lastTree = nil
end
end
end
end
Вот код теперь посмотрите в чём я тут ошибся