Загрузка данных


-- STREAMING_CHUNK:Initializing configuration and dependencies...
local moonloader = require 'moonloader'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local render_enabled = true
local render_font = nil
local COLOR_TRACER = 0xFF00FFCC
local COLOR_BOX = 0xFFFF9900
local COLOR_TEXT = 0xFFFFFFFF
local COLOR_BG = 0x80000000
local ORE_KEYWORDS = {
"руда", "камень", "залежи", "серебро", "золото",
"металл", "бронза", "алмаз", "уголь", "железо", "ресурс"
}
local ROCK_MODELS = {
[3929] = "Камень", [3930] = "Руда", [3931] = "Залежи",
[1270] = "Порода", [1271] = "Минерал", [902] = "Камень", [903] = "Руда"
}
-- STREAMING_CHUNK:Defining helper encoding and draw functions...
local function toCP1251(str)
return u8:decode(str)
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 = string.lower(text)
for _, keyword in ipairs(ORE_KEYWORDS) do
if string.find(lower_text, keyword) then
return true
end
end
return false
end
-- STREAMING_CHUNK:Scanning 3D Text labels and objects in stream zone...
local function scanMineResources()
local resources = {}
if getAll3dTextLabels then
for _, id in ipairs(getAll3dTextLabels()) 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", " ")
table.insert(resources, {x = x, y = y, z = z, name = clean_text})
end
end
end
else
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", " ")
table.insert(resources, {x = x, y = y, z = z, name = clean_text})
end
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 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
-- STREAMING_CHUNK:Initializing main loop and command handler...
function main()
while not isSampAvailable() do wait(100) end
render_font = renderCreateFont("Arial", 9, 5)
local msg_loaded = toCP1251("[Mine Render]: Скрипт загружен! Активация/деактивация: /kamen")
sampAddChatMessage(msg_loaded, 0x0088FF)
local function toggleRender()
render_enabled = not render_enabled
local status_str = render_enabled and toCP1251("[Mine Render]: Статус: {00FF00}ВКЛЮЧЕН") or toCP1251("[Mine Render]: Статус: {FF0000}ВЫКЛЮЧЕН")
sampAddChatMessage(status_str, 0xFFFFFF)
end
sampRegisterChatCommand("kamen", toggleRender)
while true do
wait(0)
pcall(renderKamen)
end
end