sampfuncsRegisterConsoleCommand("frf", function(arg)
--local segment = cars.segment3[1]
--setCharCoordinates(PLAYER_PED, segment[1], segment[2], segment[3])
sampAddChatMessage(arg,-1)
end)
renderSetRenderState(161 --[[D3DRS_MULTISAMPLEANTIALIAS]], 1)
while true do wait(0)
-- получение сегмента(и координат) игрока
local playerX, playerY = getCharCoordinates(PLAYER_PED)
local tileID, tileX, tileY = getTileFromCoordinates(playerX, playerY)
local segment = 'segment' .. tileID - 1
local nodes = cars[segment]
local links = link[segment]
-- рендер красивого текста под чатом
local debugText = string.format("Coordinates {FB7000}(%d, %d) {ffffff}belong to segment {FB7000}%d {ffffff}(%d, %d)",
math.floor(playerX), math.floor(playerY), tileID, tileX, tileY)
local debugTextShadow = string.format("Coordinates (%d, %d) belong to segment %d (%d, %d)",
math.floor(playerX), math.floor(playerY), tileID, tileX, tileY)
renderFontDrawText(Monocraft12b, debugTextShadow, 44, 171.5, 0xFF000000)
renderFontDrawText(Monocraft12d, debugText, 43, 170, 0xFFFFFFFF)
for i, node in ipairs(nodes) do
local nodeX, nodeY, nodeZ = unpack(node)
local linkID = node[4]
local linkedCount = get_first_four_bits(node[8])
local linkedIDs = {} -- { linkedID, linkedSegment }
for i = linkID, linkID + (linkedCount-1) do
local linkedID = links[linkID + 1][2] + 1
local linkedSeg = links[linkID + 1][1] + 1
linkedIDs[#linkedIDs+1] = { linkedID, linkedSeg }
--sampAddChatMessage( i ,-1)
end
local camX, camY, camZ = getActiveCameraCoordinates()
if isPointOnScreen(nodeX, nodeY, nodeZ, 3) then
local losClear = isLineOfSightClear(camX, camY, camZ, nodeX, nodeY, nodeZ + 1.5, true, true, true, true, false)
if losClear then
local boxX, boxY = convert3DCoordsToScreen(nodeX, nodeY, nodeZ)
local distance = getDistanceBetweenCoords3d(nodeX, nodeY, nodeZ, camX, camY, camZ)
local boxSize = 50 / (1 + distance * 0.1)
renderDrawBoxWithBorder(boxX, boxY, boxSize, boxSize, 0xFFFF0000, boxSize * 0.1, 0xFF000000)
if distance < 100 then
local font = Monocraft8d
local opacity = string.format("%x", (1 - (distance / 100)) * 255)
local color1 = '0x' .. opacity .. '000000'
local color2 = '0x' .. opacity .. 'FFFFFF'
local shadowOffsetX = 5
local shadowOffsetY = 2
local columnHeight = 12
renderFontDrawText(font, 'nodeID: ' .. i, boxX + shadowOffsetX, boxY + shadowOffsetY, tonumber(color1))
renderFontDrawText(font, 'nodeID: ' .. i, boxX + shadowOffsetY, boxY, tonumber(color2))
renderFontDrawText(font, 'linkID: ' .. linkID, boxX + shadowOffsetX, boxY + shadowOffsetY + columnHeight*1, tonumber(color1))
renderFontDrawText(font, 'linkID: ' .. linkID, boxX + 3, boxY + columnHeight*1, tonumber(color2))
--renderFontDrawText(font, 'linkedID: ' .. linkedID, boxX + shadowOffsetX, boxY + shadowOffsetY + columnHeight*2, tonumber(color1))
--renderFontDrawText(font, 'linkedID: ' .. linkedID, boxX + 3, boxY + columnHeight*2, tonumber(color2))
renderFontDrawText(font, 'links: ' .. linkedCount, boxX + shadowOffsetX, boxY + shadowOffsetY + columnHeight*3, tonumber(color1))
renderFontDrawText(font, 'links: ' .. linkedCount, boxX + 3, boxY + columnHeight*3, tonumber(color2))
end
end
end
for i, val in ipairs(linkedIDs) do
local linkedID = val[1]
local linkedSeg = val[2]
local linkedNode = cars['segment' .. linkedSeg-1][linkedID]
local linkX, linkY, linkZ = unpack(linkedNode)
if isPointOnScreen(linkX, linkY, linkZ, 0) then
local losClear = isLineOfSightClear(camX, camY, camZ, linkX, linkY, linkZ + 1.5, true, true, true, true, false)
if losClear then
local boxX, boxY = convert3DCoordsToScreen(nodeX, nodeY, nodeZ)
local linkedX, linkedY = convert3DCoordsToScreen(linkX, linkY, linkZ)
if i == 1 then
color = 0xFFFF0000
elseif i == 2 then
color = 0xFF00FF00
elseif i == 3 then
color = 0xFF0000FF
elseif i == 4 then
color = 0xFFFFFF00
end
renderDrawLine(boxX, boxY, linkedX, linkedY, 1, color)
end
end
end
end
end