код для рендера

francksgot

Новичок
Автор темы
12
5
Версия MoonLoader
.026-beta
скиньте пж норм код для рендера
попробовал сам сделать, но линии не отрисовываются
приложил свой код
код:
   while true do
        wait(0)
        if activ then
            local nearestObject = nil
            local minDistance = math.huge

          
            for _, obj_hand in pairs(getAllObjects()) do
                local modelid = getObjectModel(obj_hand)
                local _obj = trees[obj_hand]
                if _obj then
                    if isObjectOnScreen(obj_hand) then
                        local x, y, z = getCharCoordinates(PLAYER_PED)
                        local res, x1, y1, z1 = getObjectCoordinates(obj_hand)
                        if res then
                            local dist = getDistanceBetweenCoords3d(x, y, z, x1, y1, z1)

                         
                            if dist < minDistance then
                                nearestObject = obj_hand
                                minDistance = dist
                            end
                        end
                    end
                end
            end

        
            if nearestObject then
                local x, y, z = getCharCoordinates(PLAYER_PED)
                local res, x1, y1, z1 = getObjectCoordinates(nearestObject)
                if res then
                    local dist = math.floor(getDistanceBetweenCoords3d(x, y, z, x1, y1, z1))
                    local c1, c2 = convert3DCoordsToScreen(x, y, z)
                    local o1, o2 = convert3DCoordsToScreen(x1, y1, z1)

                  
                    sampAddChatMessage("Player: (" .. x .. ", " .. y .. ", " .. z .. ")", -1)
                    sampAddChatMessage("Object: (" .. x1 .. ", " .. y1 .. ", " .. z1 .. ")", -1)
                    sampAddChatMessage("Screen coords: (" .. c1 .. ", " .. c2 .. ") to (" .. o1 .. ", " .. o2 .. ")", -1)

                  
                    if c1 and c2 and o1 and o2 then
                        renderDrawLine(c1, c2, o1, o2, 1, 0xFFFFFFFF)
                        renderFontDrawText(font,
                            '{00FF00}' .. trees[nearestObject] .. '\n{C0C0C0}Дистанция: ' .. dist .. 'm.', o1, o2, -1,
                            false)
                    else
                        sampAddChatMessage("Error in converting coordinates.", -1)
                    end

                    if autoalt and dist < 1 then
                        setGameKeyState(21, 255)
                        wait(2)
                        setGameKeyState(21, 0)
                    end
                else
                    sampAddChatMessage("Error getting object coordinates.", -1)
                end
            else
                sampAddChatMessage("No nearest object found.", -1)
            end
        end
    end
end
 
Последнее редактирование:
  • Нравится
Реакции: santov

francksgot

Новичок
Автор темы
12
5
Lua:
local _obj = trees[obj_hand]
if _obj then

А эта проверка зачем собственно?
У тебя же даже нет trees в коде
Если trees за кодом, покажи что он из себя представляет
Lua:
local trees = {
    [5024] = 'Дерево',
    [5655] = 'Дерево',
    [2651] = 'Дерево',
    [2653] = 'Дерево'
}