local array = {}
local function GetNearest3DText(search)
for i = 0, 2049 do
if sampIs3dTextDefined(i) then
local text, color, x, y, z, distance, ignoreWalls, playerId, vehicleId = sampGet3dTextInfoById(i)
local myX, myY, myZ = getCharCoordinates(PLAYER_PED)
local distance = getDistanceBetweenCoords3d(myX, myY, myZ, x, y, z)
if text:find(search) then
table.insert(array, {['text'] = text, ['position'] = {x, y, z}, ['distance'] = distance})
end
end
end
if #array >= 1 then
table.sort( array, function(a, b) return (a.distance < b.distance) end)
return true, array[1].text, array[1].position, array[1].distance
end
return false
end
local result, text, position, distance = GetNearest3DText('Привет') -- Поиск ближайшего 3д-текста с текстом 'Привет'
if result then
print(text)
print(position[1]) -- x
print(position[2]) -- y
print(position[3]) -- z
print(distance)
end