Помогите с renderDrawLine

Marat Krutoi

Участник
Автор темы
56
9
Версия MoonLoader
.026-beta
У меня такая проблема что если у меня сзади стоит игрок то renderDrawLine показывает его спереди
(в бх я фотку загрузить не могу и на это есть причина но загрузил в imgur)
Скрин с игры где я вперед смотрю
Скрин с игры где я назад смотрю


Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        for k, v in pairs(getAllChars()) do
            if v ~= PLAYER_PED then
                local c = getCharModelCornersIn2d(getCharModel(v), v)
                local X, Y = getScreenResolution()
                renderFigure2D(X/2, Y/2, 100, 250, 0xFF4682B4) -- нарисует круг с белой
                local x, y, z = getCharCoordinates(PLAYER_PED)
                local possaX, possaY, possaZ = getScreenResolution()
                local posX, posY = convert3DCoordsToScreen(x, y, z)
                local player = getNearCharToCenter(200)
                local color = tonumber("0xFF"..(("%X"):format(sampGetPlayerColor(id))):gsub(".*(......)", "%1"))--sampGetPlayerColor(id)
                local result, id = sampGetPlayerIdByCharHandle(v)
            end
            if player then
                local playerId = select(2, sampGetPlayerIdByCharHandle(player))
                local playerNick = sampGetPlayerNickname(playerId)
                local x2, y2, z2 = getCharCoordinates(player)
                local isScreen = isPointOnScreen(x2, y2, z2, 200)
            end   
            if isScreen then
                renderDrawLine(c[1][1], c[1][2], c[2][1], c[2][2], 2, 0xFF4682B4)
                renderDrawLine(c[2][1], c[2][2], c[3][1], c[3][2], 2, 0xFF4682B4)
                renderDrawLine(c[3][1], c[3][2], c[4][1], c[4][2], 2, 0xFF4682B4)
                renderDrawLine(c[4][1], c[4][2], c[1][1], c[1][2], 2, 0xFF4682B4)
                renderDrawLine(c[5][1], c[5][2], c[6][1], c[6][2], 2, 0xFF4682B4)
                renderDrawLine(c[6][1], c[6][2], c[7][1], c[7][2], 2, 0xFF4682B4)
                renderDrawLine(c[7][1], c[7][2], c[8][1], c[8][2], 2, 0xFF4682B4)
                renderDrawLine(c[8][1], c[8][2], c[5][1], c[5][2], 2, 0xFF4682B4)
                renderDrawLine(c[1][1], c[1][2], c[5][1], c[5][2], 2, 0xFF4682B4)
                renderDrawLine(c[2][1], c[2][2], c[8][1], c[8][2], 2, 0xFF4682B4)
                renderDrawLine(c[3][1], c[3][2], c[7][1], c[7][2], 2, 0xFF4682B4)
                renderDrawLine(c[4][1], c[4][2], c[6][1], c[6][2], 2, 0xFF4682B4)
                renderDrawPolygon(X/2, Y/2, 10, 10, 7, 5, 0xFF4682B4)
                local posX2, posY2 = convert3DCoordsToScreen(x2, y2, z2)
                renderDrawLine(X/2, Y/2, posX2, posY2, 2.0, 0xFF4682B4)
                renderDrawPolygon(posX2, posY2, 10, 10, 40, 0, 0xFF4682B4)
                local distance = math.floor(getDistanceBetweenCoords3d(x, y, z, x2, y2, z2))
                renderFontDrawTextAlign(font, string.format('%s[%d]', playerNick, playerId),posX2, posY2-30, 0xFF4682B4, 2)
                renderFontDrawTextAlign(font, string.format('Дистанция: %s', distance),X/2, Y/2+210, 0xFF4682B4, 2)
                renderFontDrawTextAlign(font, 'R - OnFoot Rvanka\nX - Incar Rvanka',X/2+300, Y/2-30, 0xFF4682B4, 1)
                if isKeyJustPressed(VK_1) then
                    sampSendChat('/re '..playerId)
                end
                if isKeyJustPressed(VK_2) then
                    sampSendChat('/frem '..playerId)
                end
                if isKeyJustPressed(VK_3) then
                    sampSendChat('/spawn '..playerId)
                end
                if isKeyJustPressed(VK_4) then
                    sampSendChat('/sethp '..playerId..' 100')
                end
                if isKeyJustPressed(VK_5) then
                    sampSendChat('/gethere '..playerId)
                end
            end
        end   
    end
end
 

FixZer

Активный
126
36
У меня такая проблема что если у меня сзади стоит игрок то renderDrawLine показывает его спереди
(в бх я фотку загрузить не могу и на это есть причина но загрузил в imgur)
Скрин с игры где я вперед смотрю
Скрин с игры где я назад смотрю


Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        for k, v in pairs(getAllChars()) do
            if v ~= PLAYER_PED then
                local c = getCharModelCornersIn2d(getCharModel(v), v)
                local X, Y = getScreenResolution()
                renderFigure2D(X/2, Y/2, 100, 250, 0xFF4682B4) -- нарисует круг с белой
                local x, y, z = getCharCoordinates(PLAYER_PED)
                local possaX, possaY, possaZ = getScreenResolution()
                local posX, posY = convert3DCoordsToScreen(x, y, z)
                local player = getNearCharToCenter(200)
                local color = tonumber("0xFF"..(("%X"):format(sampGetPlayerColor(id))):gsub(".*(......)", "%1"))--sampGetPlayerColor(id)
                local result, id = sampGetPlayerIdByCharHandle(v)
            end
            if player then
                local playerId = select(2, sampGetPlayerIdByCharHandle(player))
                local playerNick = sampGetPlayerNickname(playerId)
                local x2, y2, z2 = getCharCoordinates(player)
                local isScreen = isPointOnScreen(x2, y2, z2, 200)
            end 
            if isScreen then
                renderDrawLine(c[1][1], c[1][2], c[2][1], c[2][2], 2, 0xFF4682B4)
                renderDrawLine(c[2][1], c[2][2], c[3][1], c[3][2], 2, 0xFF4682B4)
                renderDrawLine(c[3][1], c[3][2], c[4][1], c[4][2], 2, 0xFF4682B4)
                renderDrawLine(c[4][1], c[4][2], c[1][1], c[1][2], 2, 0xFF4682B4)
                renderDrawLine(c[5][1], c[5][2], c[6][1], c[6][2], 2, 0xFF4682B4)
                renderDrawLine(c[6][1], c[6][2], c[7][1], c[7][2], 2, 0xFF4682B4)
                renderDrawLine(c[7][1], c[7][2], c[8][1], c[8][2], 2, 0xFF4682B4)
                renderDrawLine(c[8][1], c[8][2], c[5][1], c[5][2], 2, 0xFF4682B4)
                renderDrawLine(c[1][1], c[1][2], c[5][1], c[5][2], 2, 0xFF4682B4)
                renderDrawLine(c[2][1], c[2][2], c[8][1], c[8][2], 2, 0xFF4682B4)
                renderDrawLine(c[3][1], c[3][2], c[7][1], c[7][2], 2, 0xFF4682B4)
                renderDrawLine(c[4][1], c[4][2], c[6][1], c[6][2], 2, 0xFF4682B4)
                renderDrawPolygon(X/2, Y/2, 10, 10, 7, 5, 0xFF4682B4)
                local posX2, posY2 = convert3DCoordsToScreen(x2, y2, z2)
                renderDrawLine(X/2, Y/2, posX2, posY2, 2.0, 0xFF4682B4)
                renderDrawPolygon(posX2, posY2, 10, 10, 40, 0, 0xFF4682B4)
                local distance = math.floor(getDistanceBetweenCoords3d(x, y, z, x2, y2, z2))
                renderFontDrawTextAlign(font, string.format('%s[%d]', playerNick, playerId),posX2, posY2-30, 0xFF4682B4, 2)
                renderFontDrawTextAlign(font, string.format('Дистанция: %s', distance),X/2, Y/2+210, 0xFF4682B4, 2)
                renderFontDrawTextAlign(font, 'R - OnFoot Rvanka\nX - Incar Rvanka',X/2+300, Y/2-30, 0xFF4682B4, 1)
                if isKeyJustPressed(VK_1) then
                    sampSendChat('/re '..playerId)
                end
                if isKeyJustPressed(VK_2) then
                    sampSendChat('/frem '..playerId)
                end
                if isKeyJustPressed(VK_3) then
                    sampSendChat('/spawn '..playerId)
                end
                if isKeyJustPressed(VK_4) then
                    sampSendChat('/sethp '..playerId..' 100')
                end
                if isKeyJustPressed(VK_5) then
                    sampSendChat('/gethere '..playerId)
                end
            end
        end 
    end
end
Lua:
isPointOnScreen(x2, y2, z2, 0)

Должно быть вот так тогда
Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        for k, v in pairs(getAllChars()) do
            if v ~= PLAYER_PED then
                local c = getCharModelCornersIn2d(getCharModel(v), v)
                local X, Y = getScreenResolution()
                renderFigure2D(X/2, Y/2, 100, 250, 0xFF4682B4) -- нарисует круг с белой
                local x, y, z = getCharCoordinates(PLAYER_PED)
                local possaX, possaY, possaZ = getScreenResolution()
                local posX, posY = convert3DCoordsToScreen(x, y, z)
                local player = getNearCharToCenter(200)
                local color = tonumber("0xFF"..(("%X"):format(sampGetPlayerColor(id))):gsub(".*(......)", "%1"))--sampGetPlayerColor(id)
                local result, id = sampGetPlayerIdByCharHandle(v)
            end
            if player then
                local playerId = select(2, sampGetPlayerIdByCharHandle(player))
                local playerNick = sampGetPlayerNickname(playerId)
                local x2, y2, z2 = getCharCoordinates(player)
                local isScreen = isPointOnScreen(x2, y2, z2, 0)
            end   
            if isScreen then
                renderDrawLine(c[1][1], c[1][2], c[2][1], c[2][2], 2, 0xFF4682B4)
                renderDrawLine(c[2][1], c[2][2], c[3][1], c[3][2], 2, 0xFF4682B4)
                renderDrawLine(c[3][1], c[3][2], c[4][1], c[4][2], 2, 0xFF4682B4)
                renderDrawLine(c[4][1], c[4][2], c[1][1], c[1][2], 2, 0xFF4682B4)
                renderDrawLine(c[5][1], c[5][2], c[6][1], c[6][2], 2, 0xFF4682B4)
                renderDrawLine(c[6][1], c[6][2], c[7][1], c[7][2], 2, 0xFF4682B4)
                renderDrawLine(c[7][1], c[7][2], c[8][1], c[8][2], 2, 0xFF4682B4)
                renderDrawLine(c[8][1], c[8][2], c[5][1], c[5][2], 2, 0xFF4682B4)
                renderDrawLine(c[1][1], c[1][2], c[5][1], c[5][2], 2, 0xFF4682B4)
                renderDrawLine(c[2][1], c[2][2], c[8][1], c[8][2], 2, 0xFF4682B4)
                renderDrawLine(c[3][1], c[3][2], c[7][1], c[7][2], 2, 0xFF4682B4)
                renderDrawLine(c[4][1], c[4][2], c[6][1], c[6][2], 2, 0xFF4682B4)
                renderDrawPolygon(X/2, Y/2, 10, 10, 7, 5, 0xFF4682B4)
                local posX2, posY2 = convert3DCoordsToScreen(x2, y2, z2)
                renderDrawLine(X/2, Y/2, posX2, posY2, 2.0, 0xFF4682B4)
                renderDrawPolygon(posX2, posY2, 10, 10, 40, 0, 0xFF4682B4)
                local distance = math.floor(getDistanceBetweenCoords3d(x, y, z, x2, y2, z2))
                renderFontDrawTextAlign(font, string.format('%s[%d]', playerNick, playerId),posX2, posY2-30, 0xFF4682B4, 2)
                renderFontDrawTextAlign(font, string.format('Дистанция: %s', distance),X/2, Y/2+210, 0xFF4682B4, 2)
                renderFontDrawTextAlign(font, 'R - OnFoot Rvanka\nX - Incar Rvanka',X/2+300, Y/2-30, 0xFF4682B4, 1)
                if isKeyJustPressed(VK_1) then
                    sampSendChat('/re '..playerId)
                end
                if isKeyJustPressed(VK_2) then
                    sampSendChat('/frem '..playerId)
                end
                if isKeyJustPressed(VK_3) then
                    sampSendChat('/spawn '..playerId)
                end
                if isKeyJustPressed(VK_4) then
                    sampSendChat('/sethp '..playerId..' 100')
                end
                if isKeyJustPressed(VK_5) then
                    sampSendChat('/gethere '..playerId)
                end
            end
        end   
    end
end
 
  • Нравится
Реакции: histor

Marat Krutoi

Участник
Автор темы
56
9
Lua:
isPointOnScreen(x2, y2, z2, 0)

Должно быть вот так тогда
Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        for k, v in pairs(getAllChars()) do
            if v ~= PLAYER_PED then
                local c = getCharModelCornersIn2d(getCharModel(v), v)
                local X, Y = getScreenResolution()
                renderFigure2D(X/2, Y/2, 100, 250, 0xFF4682B4) -- нарисует круг с белой
                local x, y, z = getCharCoordinates(PLAYER_PED)
                local possaX, possaY, possaZ = getScreenResolution()
                local posX, posY = convert3DCoordsToScreen(x, y, z)
                local player = getNearCharToCenter(200)
                local color = tonumber("0xFF"..(("%X"):format(sampGetPlayerColor(id))):gsub(".*(......)", "%1"))--sampGetPlayerColor(id)
                local result, id = sampGetPlayerIdByCharHandle(v)
            end
            if player then
                local playerId = select(2, sampGetPlayerIdByCharHandle(player))
                local playerNick = sampGetPlayerNickname(playerId)
                local x2, y2, z2 = getCharCoordinates(player)
                local isScreen = isPointOnScreen(x2, y2, z2, 0)
            end 
            if isScreen then
                renderDrawLine(c[1][1], c[1][2], c[2][1], c[2][2], 2, 0xFF4682B4)
                renderDrawLine(c[2][1], c[2][2], c[3][1], c[3][2], 2, 0xFF4682B4)
                renderDrawLine(c[3][1], c[3][2], c[4][1], c[4][2], 2, 0xFF4682B4)
                renderDrawLine(c[4][1], c[4][2], c[1][1], c[1][2], 2, 0xFF4682B4)
                renderDrawLine(c[5][1], c[5][2], c[6][1], c[6][2], 2, 0xFF4682B4)
                renderDrawLine(c[6][1], c[6][2], c[7][1], c[7][2], 2, 0xFF4682B4)
                renderDrawLine(c[7][1], c[7][2], c[8][1], c[8][2], 2, 0xFF4682B4)
                renderDrawLine(c[8][1], c[8][2], c[5][1], c[5][2], 2, 0xFF4682B4)
                renderDrawLine(c[1][1], c[1][2], c[5][1], c[5][2], 2, 0xFF4682B4)
                renderDrawLine(c[2][1], c[2][2], c[8][1], c[8][2], 2, 0xFF4682B4)
                renderDrawLine(c[3][1], c[3][2], c[7][1], c[7][2], 2, 0xFF4682B4)
                renderDrawLine(c[4][1], c[4][2], c[6][1], c[6][2], 2, 0xFF4682B4)
                renderDrawPolygon(X/2, Y/2, 10, 10, 7, 5, 0xFF4682B4)
                local posX2, posY2 = convert3DCoordsToScreen(x2, y2, z2)
                renderDrawLine(X/2, Y/2, posX2, posY2, 2.0, 0xFF4682B4)
                renderDrawPolygon(posX2, posY2, 10, 10, 40, 0, 0xFF4682B4)
                local distance = math.floor(getDistanceBetweenCoords3d(x, y, z, x2, y2, z2))
                renderFontDrawTextAlign(font, string.format('%s[%d]', playerNick, playerId),posX2, posY2-30, 0xFF4682B4, 2)
                renderFontDrawTextAlign(font, string.format('Дистанция: %s', distance),X/2, Y/2+210, 0xFF4682B4, 2)
                renderFontDrawTextAlign(font, 'R - OnFoot Rvanka\nX - Incar Rvanka',X/2+300, Y/2-30, 0xFF4682B4, 1)
                if isKeyJustPressed(VK_1) then
                    sampSendChat('/re '..playerId)
                end
                if isKeyJustPressed(VK_2) then
                    sampSendChat('/frem '..playerId)
                end
                if isKeyJustPressed(VK_3) then
                    sampSendChat('/spawn '..playerId)
                end
                if isKeyJustPressed(VK_4) then
                    sampSendChat('/sethp '..playerId..' 100')
                end
                if isKeyJustPressed(VK_5) then
                    sampSendChat('/gethere '..playerId)
                end
            end
        end 
    end
end
теперь вообще кроме круга ничего не показывается
1693421409392.png
 

Z3roKwq

Известный
294
157
Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        for k, v in pairs(getAllChars()) do
            if v ~= PLAYER_PED then
                local c = getCharModelCornersIn2d(getCharModel(v), v)
                local X, Y = getScreenResolution()
                renderFigure2D(X/2, Y/2, 100, 250, 0xFF4682B4) -- нарисует круг с белой
                local x, y, z = getCharCoordinates(PLAYER_PED)
                local possaX, possaY, possaZ = getScreenResolution()
                local posX, posY = convert3DCoordsToScreen(x, y, z)
                local player = getNearCharToCenter(200)
                local color = tonumber("0xFF"..(("%X"):format(sampGetPlayerColor(id))):gsub(".*(......)", "%1"))--sampGetPlayerColor(id)
                local result, id = sampGetPlayerIdByCharHandle(v)
            end
            if player then
                local playerId = select(2, sampGetPlayerIdByCharHandle(player))
                local playerNick = sampGetPlayerNickname(playerId)
                local x2, y2, z2 = getCharCoordinates(player)
                local _, handle = sampGetCharHandleBySampPlayerId(playerId)
                -- local isScreen = isPointOnScreen(x2, y2, z2, 200)
            end   
            if isCharOnScreen(handle) then
                renderDrawLine(c[1][1], c[1][2], c[2][1], c[2][2], 2, 0xFF4682B4)
                renderDrawLine(c[2][1], c[2][2], c[3][1], c[3][2], 2, 0xFF4682B4)
                renderDrawLine(c[3][1], c[3][2], c[4][1], c[4][2], 2, 0xFF4682B4)
                renderDrawLine(c[4][1], c[4][2], c[1][1], c[1][2], 2, 0xFF4682B4)
                renderDrawLine(c[5][1], c[5][2], c[6][1], c[6][2], 2, 0xFF4682B4)
                renderDrawLine(c[6][1], c[6][2], c[7][1], c[7][2], 2, 0xFF4682B4)
                renderDrawLine(c[7][1], c[7][2], c[8][1], c[8][2], 2, 0xFF4682B4)
                renderDrawLine(c[8][1], c[8][2], c[5][1], c[5][2], 2, 0xFF4682B4)
                renderDrawLine(c[1][1], c[1][2], c[5][1], c[5][2], 2, 0xFF4682B4)
                renderDrawLine(c[2][1], c[2][2], c[8][1], c[8][2], 2, 0xFF4682B4)
                renderDrawLine(c[3][1], c[3][2], c[7][1], c[7][2], 2, 0xFF4682B4)
                renderDrawLine(c[4][1], c[4][2], c[6][1], c[6][2], 2, 0xFF4682B4)
                renderDrawPolygon(X/2, Y/2, 10, 10, 7, 5, 0xFF4682B4)
                local posX2, posY2 = convert3DCoordsToScreen(x2, y2, z2)
                renderDrawLine(X/2, Y/2, posX2, posY2, 2.0, 0xFF4682B4)
                renderDrawPolygon(posX2, posY2, 10, 10, 40, 0, 0xFF4682B4)
                local distance = math.floor(getDistanceBetweenCoords3d(x, y, z, x2, y2, z2))
                renderFontDrawTextAlign(font, string.format('%s[%d]', playerNick, playerId),posX2, posY2-30, 0xFF4682B4, 2)
                renderFontDrawTextAlign(font, string.format('Дистанция: %s', distance),X/2, Y/2+210, 0xFF4682B4, 2)
                renderFontDrawTextAlign(font, 'R - OnFoot Rvanka\nX - Incar Rvanka',X/2+300, Y/2-30, 0xFF4682B4, 1)
                if isKeyJustPressed(VK_1) then
                    sampSendChat('/re '..playerId)
                end
                if isKeyJustPressed(VK_2) then
                    sampSendChat('/frem '..playerId)
                end
                if isKeyJustPressed(VK_3) then
                    sampSendChat('/spawn '..playerId)
                end
                if isKeyJustPressed(VK_4) then
                    sampSendChat('/sethp '..playerId..' 100')
                end
                if isKeyJustPressed(VK_5) then
                    sampSendChat('/gethere '..playerId)
                end
            end
        end   
    end
end

попробуй