Загрузка данных
-- ... existing code ...
local ORE_KEYWORDS = {
"руда", "камень", "залежи", "серебро", "золото",
"металл", "бронза", "алмаз", "уголь", "железо", "ресурс",
"порода", "минерал", "аметист", "рубин", "изумруд", "прочность", "шахта"
}
local ROCK_MODELS = {
[3929] = "Камень", [3930] = "Руда", [3931] = "Залежи",
[1270] = "Порода", [1271] = "Минерал", [1272] = "Камень", [1273] = "Руда", [1274] = "Залежи",
[902] = "Камень", [903] = "Руда", [19341] = "Руда", [19342] = "Камень", [19343] = "Залежи",
[19344] = "Минерал", [19345] = "Алмаз", [19346] = "Золто"
}
-- STREAMING_CHUNK:Defining helper encoding and draw functions...
local function toCP1251(str)
return u8:decode(str)
end
-- STREAMING_CHUNK:Converting CP1251 Cyrillic string to lowercase...
local function cp1251_lower(str)
if not str then return "" end
local result = {}
for i = 1, #str do
local byte = string.byte(str, i)
if byte >= 65 and byte <= 90 then
byte = byte + 32
elseif byte >= 192 and byte <= 223 then
byte = byte + 32
elseif byte == 168 then
byte = 184
end
table.insert(result, string.char(byte))
end
return table.concat(result)
end
local function drawBoxBorder(x, y, w, h, thickness, color)
renderDrawBox(x, y, w, thickness, color)
renderDrawBox(x, y + h - thickness, w, thickness, color)
renderDrawBox(x, y, thickness, h, color)
renderDrawBox(x + w - thickness, y, thickness, h, color)
end
local function isOreText(text)
if not text then return false end
local lower_text = cp1251_lower(text)
for _, keyword in ipairs(ORE_KEYWORDS) do
if string.find(lower_text, keyword, 1, true) then
return true
end
end
return false
end
-- STREAMING_CHUNK:Scanning 3D Text labels and objects in stream zone...
local function scanMineResources()
local resources = {}
for id = 0, 2047 do
if sampIs3dTextDefined(id) then
local text, color, x, y, z = sampGet3dTextInfoById(id)
if text and isOreText(text) then
local clean_text = text:gsub("{......}", ""):gsub("\n", " ")
if #clean_text > 30 then
clean_text = clean_text:sub(1, 30) .. "..."
end
table.insert(resources, {x = x, y = y, z = z, name = clean_text})
end
end
end
for _, handle in ipairs(getAllObjects()) do
if doesObjectExist(handle) then
local model = getObjectModel(handle)
if ROCK_MODELS[model] then
local ox, oy, oz = getObjectCoordinates(handle)
table.insert(resources, {x = ox, y = oy, z = oz, name = ROCK_MODELS[model]})
end
end
end
return resources
end
-- STREAMING_CHUNK:Rendering visual overlays and tracer lines...
function renderKamen()
if not render_enabled then return end
local my_ped = PLAYER_PED
if not doesCharExist(my_ped) then return end
local render_w, render_h = getScreenResolution()
local my_x, my_y, my_z = getCharCoordinates(my_ped)
local origin_x = render_w / 2
local origin_y = render_h
local resources = scanMineResources()
for _, item in ipairs(resources) do
local dist = getDistanceBetweenCoords3d(my_x, my_y, my_z, item.x, item.y, item.z)
if dist <= 200.0 and isPointOnScreen(item.x, item.y, item.z, 0.0) then
local sx, sy = convert3DCoordsToScreen(item.x, item.y, item.z)
local hx, hy = convert3DCoordsToScreen(item.x, item.y, item.z + 0.6)
local bx, by = convert3DCoordsToScreen(item.x, item.y, item.z - 0.4)
if sx and sy and hx and hy and bx and by then
renderDrawLine(origin_x, origin_y, sx, sy, 1.5, COLOR_TRACER)
local box_h = math.abs(by - hy)
if box_h < 15 then box_h = 15 end
local box_w = box_h * 0.9
local box_x = sx - (box_w / 2)
local box_y = hy
drawBoxBorder(box_x, box_y, box_w, box_h, 1.5, COLOR_BOX)
local label_str = string.format("%s [%d%s]", item.name, math.floor(dist), toCP1251("м"))
if render_font then
local text_len = renderGetFontDrawTextLength(render_font, label_str)
renderFontDrawText(render_font, label_str, box_x + (box_w / 2) - (text_len / 2), box_y - 16, COLOR_TEXT)
end
end
end
end
end
-- ... existing code ...