script_dependencies("CLEO", "SAMP", "SAMPFUNCS")
---------------------------------------------------------------------------
require "lib.moonloader"
require "lib.sampfuncs"
---------------------------------------------------------------------------
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
sampRegisterChatCommand("mycmd", cmd)
while true do wait(0) end
end
function cmd(param)
if isPlayerPlaying(playerHandle) then
local posX, posY, posZ = getCharCoordinates(playerPed)
local res, text, color, x, y, z, distance, ignoreWalls, player, vehicle = Search3Dtext(posX, posY, posZ, 50.0, "")
if res then
sampAddChatMessage(string.format("Найден 3D текст \"%s\" в координатах %.2f %.2f %.2f, дистанция %.2f, id игрока %d, id транспорта %d", text, x, y, z, distance, player, vehicle), color)
end
end
end
function Search3Dtext(x, y, z, radius, patern)
local text = ""
local color = 0
local posX = 0.0
local posY = 0.0
local posZ = 0.0
local distance = 0.0
local ignoreWalls = false
local player = -1
local vehicle = -1
local result = false
for id = 0, 2048 do
if sampIs3dTextDefined(id) then
local text2, color2, posX2, posY2, posZ2, distance2, ignoreWalls2, player2, vehicle2 = sampGet3dTextInfoById(id)
if getDistanceBetweenCoords3d(x, y, z, posX2, posY2, posZ2) < radius then
if string.len(patern) ~= 0 then
if string.match(text2, patern, 0) ~= nil then result = true end
else
result = true
end
if result then
text = text2
color = color2
posX = posX2
posY = posY2
posZ = posZ2
distance = distance2
ignoreWalls = ignoreWalls2
player = player2
vehicle = vehicle2
radius = getDistanceBetweenCoords3d(x, y, z, posX, posY, posZ)
end
end
end
end
return result, text, color, posX, posY, posZ, distance, ignoreWalls, player, vehicle
end