-- Тут без дистанции, текстом выводится ID 3dTextLabel
local ffi = require 'ffi'
ffi.cdef[[
struct stTextLabel
{
char *pText;
unsigned long color;
float fPosition[3];
float fMaxViewDistance;
unsigned char byteShowBehindWalls;
unsigned short sAttachedToPlayerID;
unsigned short sAttachedToVehicleID;
}__attribute__((packed));
struct stTextLabelPool
{
struct stTextLabel textLabel[2048];
int iIsListed[2048];
}__attribute__((packed));
]]
local font = renderCreateFont("Tahoma", 14, 5)
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
repeat wait(100) until isSampAvailable()
while true do wait(0)
local pool = sampGetAllTextLabels()
for i = 1, #pool do
if isPointOnScreen(pool[i].pos.x, pool[i].pos.y, pool[i].pos.z, 300) then
local pposX, pposY = convert3DCoordsToScreen(getCharCoordinates(PLAYER_PED))
local tposX, tposY = convert3DCoordsToScreen(pool[i].pos.x, pool[i].pos.y, pool[i].pos.z)
renderDrawLine(pposX, pposY, tposX, tposY, 2.0, 0xFFFF2020)
renderFontDrawText(font, tostring(pool[i].id), tposX, tposY, 0xFFFFFFFF)
end
end
end
end
function sampGetAllTextLabels()
local pool = ffi.cast("struct stTextLabelPool*", sampGetTextlabelPoolPtr())
local labels_tbl = {}
for i = 0, 2048 do
if pool.iIsListed[i] ~= 0 and pool.textLabel[i] ~= nil then
table.insert(
labels_tbl,
{
id = i,
text = pool.textLabel[i].pText,
color = pool.textLabel[i].color,
pos = { x = pool.textLabel[i].fPosition[0], y = pool.textLabel[i].fPosition[1], z = pool.textLabel[i].fPosition[2] },
maxViewDist = pool.textLabel[i].fMaxViewDistance,
showBehindWalls = pool.textLabel[i].byteShowBehindWalls,
attachedPlayerId = pool.textLabel[i].sAttachedToPlayerID,
attachedVehicleId = pool.textLabel[i].sAttachedToVehicleID
}
)
end
end
return labels_tbl
end