Ошибка помогите плс.

Krtixikteq

Новичок
Автор темы
25
0
Версия MoonLoader
Другое
Крч решил не много изменить скрипт от хистора трешер тулс, решил удалить 1 кнопку с вопросами и ответами на клады. в итоге выбивает ошибку, а разобраться не могу так как только начинаю программировать.
Ошибка:
:101002: ')' expected (to close '(' at line 857) near 'imgui'
Просьба помочь с скриптом:
Вот сам код:
script_name('treasuretools')
script_author('histor')
script_description('helper for arz players')
script_version('8')
require "lib.moonloader"
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local imgui = require 'mimgui'
local keys = require "vkeys"
local key = keys.VK_O
local ffi = require 'ffi'
local wm = require 'windows.message'
local new = imgui.new
local sampev = require 'lib.samp.events'
local inicfg = require "inicfg"
local directIni = "config//th8.ini"
local sizeX, sizeY = getScreenResolution()
local renderWindow = new.bool(false)
local new, str, sizeof = imgui.new, ffi.string, ffi.sizeof
local prf = "1488"
local font = {}
local search = new.char[256]()
local zoneActive = false
local mapUsed = false
local kdcond = false
local endkd = 'xx:xx:xx'
local fullmap = true
local coords = {}
local pool = {}
local finded = {}
local markers = {}
local rekey = false
local check = false
local check2 = false
local yavdemorgane = false
local xforklad, yforklad, zforklad = 0, 0, 0


local lower, sub, char, upper = string.lower, string.sub, string.char, string.upper
local concat = table.concat

-- initialization table
local lu_rus, ul_rus = {}, {}
for i = 192, 223 do
    local A, a = char(i), char(i + 32)
    ul_rus[A] = a
    lu_rus[a] = A
end
local E, e = char(168), char(184)
ul_rus[E] = e
lu_rus[e] = E

function string.nlower(s)
    s = lower(s)
    local len, res = #s, {}
    for i = 1, len do
        local ch = sub(s, i, i)
        res[i] = ul_rus[ch] or ch
    end
    return concat(res)
end

local mainini =
    inicfg.load(
        {th = {
                bnotfonscreen = false,
                bnotfinchat = false,
                bsoundnotf = false,
                brender = false,
                btraser = false,
                bpointsonmap = false,
                bmarkers = false,
                bshovel = false,
                bdemorgan = false,
                btmr = false,
                sliderint1 = 500,
                sliderint2 = 15,
                int = 10,
                bcolorint1 = 0,
                bcolorint2 = 1,
                colortest1 = 0xFFFFFFFF,
                colortest2 = 0xFFFFFFFF,
                c3r1 = 1.0,
                c3r2 = 1.0,
                c3r3 = 1.0,
                c3t1 = 1.0,
                c3t2 = 1.0,
                c3t3 = 1.0,
                btmrr = false,
                bpc = false,
                bdmg = false
        }},"th8")
inicfg.save(mainini, 'th8.ini')

local nnint = 0
local nnint1 = 1
local nnint2 = 2
local colortest1 = mainini.th.colortest1
local colortest2 = mainini.th.colortest2

local color3render = imgui.new.float[3](mainini.th.c3r1, mainini.th.c3r2, mainini.th.c3r3)
local color3traser = imgui.new.float[3](mainini.th.c3t1, mainini.th.c3t2, mainini.th.c3t3)

local bnotfonscreen = new.bool(mainini.th.bnotfonscreen)
local bnotfinchat = new.bool(mainini.th.bnotfinchat)
local bsoundnotf = new.bool(mainini.th.bsoundnotf)
local brender = new.bool(mainini.th.brender)
local btraser = new.bool(mainini.th.btraser)
local bpointsonmap = new.bool(mainini.th.bpointsonmap)
local bmarkers = new.bool(mainini.th.bmarkers)
local bshovel = new.bool(mainini.th.bshovel)
local btmr = new.bool(mainini.th.btmr)
local btmrr = new.bool(mainini.th.btmrr)
local bpc = new.bool(mainini.th.bpc)
local bdmg = new.bool(mainini.th.bdmg)

local sliderint1 = new.int(mainini.th.sliderint1)
local sliderint2 = new.int(mainini.th.sliderint2)
local int = new.int(mainini.th.int)

local bcolorint1 = new.int(mainini.th.bcolorint1)
local bcolorint2 = new.int(mainini.th.bcolorint2)
local combo_int1 = new.int(bcolorint1[0])
local combo_int2 = new.int(bcolorint2[0])

local combo_colors = {
    u8'[1]Зелёный',
    u8'[2]Жёлтый',
    u8'[3]Красный',
    u8'[4]Синий',
    u8'[5]Рыжий',
    u8'[6]Белый',
    u8'[7]Розовый',
    u8'[8]Серый',
    u8'[9]Голубой',
    u8'[10]Малиновый'
}
local blip_color = {
    '0x00FF00FF',
    '0xFFFF00FF',
    '0xFF0000FF',
    '0x6666FFFF',
    '0xFF5000FF',
    '0xFFFFFFFF',
    '0xFF00FFFF',
    '0xAAAAAAFF',
    '0x00FFFFFF',
    '0xFF6060FF'
}
local ImItems = imgui.new['const char*'][#combo_colors](combo_colors)

function white_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    local ImVec2 = imgui.ImVec2

    imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    imgui.GetStyle().ButtonTextAlign    = imgui.ImVec2(0.5, 0.5)
    imgui.GetStyle().WindowPadding = imgui.ImVec2(5, 5)
    imgui.GetStyle().FramePadding = imgui.ImVec2(5, 5)
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(5, 5)
    imgui.GetStyle().ItemInnerSpacing = imgui.ImVec2(2, 2)
    imgui.GetStyle().TouchExtraPadding = imgui.ImVec2(0, 0)
    imgui.GetStyle().IndentSpacing = 0

    --==[ BORDER ]==--
    imgui.GetStyle().WindowBorderSize = 1
    imgui.GetStyle().ChildBorderSize = 1
    imgui.GetStyle().PopupBorderSize = 1
    imgui.GetStyle().FrameBorderSize = 1
    imgui.GetStyle().TabBorderSize = 1
    imgui.GetStyle().ScrollbarSize = 15
    imgui.GetStyle().GrabMinSize = 10

    --==[ ROUNDING ]==--
    imgui.GetStyle().WindowRounding = 8
    imgui.GetStyle().ChildRounding = 8
    imgui.GetStyle().FrameRounding = 8
    imgui.GetStyle().PopupRounding = 8
    imgui.GetStyle().ScrollbarRounding = 10
    imgui.GetStyle().GrabRounding = 8
    imgui.GetStyle().TabRounding = 8

    colors[clr.Text]                   = ImVec4(0.95, 0.96, 0.98, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.29, 0.29, 0.29, 1.00)
    colors[clr.WindowBg]               = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.FrameBg]                = ImVec4(0.22, 0.22, 0.22, 1.00)
    colors[clr.FrameBgHovered]         = ImVec4(0.18, 0.18, 0.18, 1.00)
    colors[clr.FrameBgActive]          = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.TitleBg]                = ImVec4(0.14, 0.14, 0.14, 0.81)
    colors[clr.TitleBgActive]          = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.MenuBarBg]              = ImVec4(0.20, 0.20, 0.20, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.ScrollbarGrab]          = ImVec4(1.00, 0.28, 0.28, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(1.00, 0.39, 0.39, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(1.00, 0.21, 0.21, 1.00)
    colors[clr.CheckMark]              = ImVec4(1.00, 0.28, 0.28, 1.00)
    colors[clr.SliderGrab]             = ImVec4(1.00, 0.28, 0.28, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(1.00, 0.28, 0.28, 1.00)
    colors[clr.Button]                 = ImVec4(1.00, 0.28, 0.28, 1.00)
    colors[clr.ButtonHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00)
    colors[clr.ButtonActive]           = ImVec4(1.00, 0.21, 0.21, 1.00)
    colors[clr.Header]                 = ImVec4(1.00, 0.28, 0.28, 1.00)
    colors[clr.HeaderHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00)
    colors[clr.HeaderActive]           = ImVec4(1.00, 0.21, 0.21, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(1.00, 0.28, 0.28, 1.00)
    colors[clr.ResizeGripHovered]      = ImVec4(1.00, 0.39, 0.39, 1.00)
    colors[clr.ResizeGripActive]       = ImVec4(1.00, 0.19, 0.19, 1.00)
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
    colors[clr.PlotHistogram]          = ImVec4(1.00, 0.21, 0.21, 1.00)
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.18, 0.18, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(1.00, 0.32, 0.32, 1.00)
    colors[clr.Border]                 = ImVec4(1.00, 0.28, 0.28, 1.00)
end

function join_argb(a, r, g, b)
    local argb = b  -- b
    argb = bit.bor(argb, bit.lshift(g, 8))  -- g
    argb = bit.bor(argb, bit.lshift(r, 16)) -- r
    argb = bit.bor(argb, bit.lshift(a, 24)) -- a
    return argb
end

function imgui.TodoCheck(label, bool, a_speed, description)

    local p  = imgui.GetCursorScreenPos()
    local dl = imgui.GetWindowDrawList()

    local clicked = false

    local label      = label or ""                               -- Название
    local outline    = 2.0                                       -- Толщина обводки
    local r          = imgui.GetTextLineHeightWithSpacing() / 2  -- Радиус кружочка
    local s          = a_speed or 0.2                            -- Скорость анимации

    local function ImSaturate(f)
        return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
    end
 
    if imgui.InvisibleButton(label, imgui.ImVec2(r * 2, r * 2)) then
        bool[0] = not bool[0]
        LastTime[label] = os.clock()
        LastActive[label] = true
        clicked = true
    end

    local w = bool[0] and 1.0 or 0.0
    local bebra = 0.0
 
    if LastTime == nil then
        LastTime = {}
    end
    if LastActive == nil then
        LastActive = {}
    end
 
    if LastActive[label] then
        local time = os.clock() - LastTime[label]
        if time <= s then
            local anim = ImSaturate(time / s)
            w = bool[0] and anim or 1.0 - anim
            bebra = anim
        else
            LastActive[label] = false
        end
    end

    local c_color = bool[0] and imgui.ImVec4(1.00, 0.28, 0.28, 1.00) or (imgui.IsItemHovered(0) and imgui.ImVec4(1, 1, 1, 0.6) or imgui.ImVec4(1, 1, 1, 0.4))  -- Цвет обводки кружочка
    local cin_color = imgui.ImVec4(1.00, 0.28, 0.28, 1.00)   -- Цвет кружочка1.00, 0.28, 0.28, 1.00
    local cline_color = imgui.ImVec4(1.00, 1.00, 1.00, w) -- Цвет галки
    local cbebra_color = imgui.ImVec4(1.00, 1.00, 1.00, (1 - bebra) * 0.2)

    dl:AddCircleFilled(imgui.ImVec2(p.x + r, p.y + r), r * bebra * 2, imgui.GetColorU32Vec4(cbebra_color), r + 5, outline)
    dl:AddCircleFilled(imgui.ImVec2(p.x + r, p.y + r), r * w, imgui.GetColorU32Vec4(cin_color), r + 5)
    dl:AddCircle(imgui.ImVec2(p.x + r, p.y + r), r, imgui.GetColorU32Vec4(c_color), r + 5, outline)
    dl:AddLine(imgui.ImVec2(p.x + r, p.y + w * (r + r / 2)), imgui.ImVec2(p.x, p.y + w * (r / 2)), imgui.GetColorU32Vec4(cline_color), outline)
    dl:AddLine(imgui.ImVec2(p.x + r, p.y + w * (r + r / 2)), imgui.ImVec2(p.x + w * (r + r / 2), p.y + w * (r / 2)), imgui.GetColorU32Vec4(cline_color), outline)
    dl:AddText(imgui.ImVec2(p.x + r * 2.7, p.y + r - (r / 2) - (imgui.CalcTextSize(label).y / 4)), imgui.GetColorU32Vec4(imgui.ImVec4(1 , 1, 1, 1)), label)
    if imgui.IsItemHovered() then
        imgui.BeginTooltip()
            imgui.PushTextWrapPos(600)
                imgui.TextUnformatted(u8(description))
            imgui.PopTextWrapPos()
        imgui.EndTooltip()
    end
    return clicked
end

function remove_all(bool_update)
    for i = 1, #coords do
        if pool[i] ~= nil then
            if bool_update then
                changeBlipColour(pool[i], finded[i] and blip_color[bcolorint1[0] + 1] or blip_color[bcolorint2[0] + 1])
            else
                removeBlip(pool[i])
                pool[i] = nil
            end
        end
    end
end

function remove_markers()
    for i, marker in pairs(markers) do
        removeUser3dMarker(marker)
        markers[i] = nil
    end
end

function plural(n, forms)
    n = math.abs(n) % 100
    if n % 10 == 1 and n ~= 11 then
        return forms[1]
    elseif 2 <= n % 10 and n % 10 <= 4 and (n < 10 or n >= 20) then
        return forms[2]
    end
    return forms[3]
end

function sampev.onSetInterior(interior)
    if true then
        if interior == 236 then
            bnotfonscreen[0] = false
            bnotfinchat[0] = false
            bsoundnotf[0] = false
            brender[0] = false
            btraser[0] = false
            bpc[0] = false
        end
    end
end

local ui_meta = {
    __index = function(self, v)
        if v == "switch" then
            local switch = function()
                if self.process and self.process:status() ~= "dead" then
                    return false -- // Предыдущая анимация ещё не завершилась!
                end
                self.timer = os.clock()
                self.state = not self.state

                self.process = lua_thread.create(function()
                    local bringFloatTo = function(from, to, start_time, duration)
                        local timer = os.clock() - start_time
                        if timer >= 0.00 and timer <= duration then
                            local count = timer / (duration / 100)
                            return count * ((to - from) / 100)
                        end
                        return (timer > duration) and to or from
                    end

                    while true do wait(0)
                        local a = bringFloatTo(0.00, 1.00, self.timer, self.duration)
                        self.alpha = self.state and a or 1.00 - a
                        if a == 1.00 then break end
                    end
                end)
                return true -- // Состояние окна изменено!
            end
            return switch
        end
 
        if v == "alpha" then
            return self.state and 1.00 or 0.00
        end
    end
}

local menu = { state = false, duration = 0.5 }
setmetatable(menu, ui_meta)

local info = { state = false, duration = 0.5 }
setmetatable(info, ui_meta)

imgui.CloseButton = function(size, thickness, textColor, color, colorHovered, colorClicked)
    local col = {
        text = textColor or imgui.GetStyle().Colors[imgui.Col.Button],
        color = color or imgui.GetStyle().Colors[imgui.Col.Button],
        colorHovered = colorHovered or imgui.GetStyle().Colors[imgui.Col.ButtonHovered],
        colorClicked = colorClicked or imgui.GetStyle().Colors[imgui.Col.ButtonActive],
    }
    local c = imgui.GetCursorPos()
    local p = imgui.GetCursorScreenPos()
    local DL = imgui.GetWindowDrawList()
    local tx = imgui.CalcTextSize('X')
    local curX, curY = getCursorPos()
    DL:AddCircle(p, size, imgui.GetColorU32Vec4(col.color), 100, thickness)
    if curX > p.x - size and curX < p.x + size then
        if curY > p.y - size and curY < p.y + size then
            DL:AddLine(imgui.ImVec2(p.x - size + thickness, p.y - size + thickness), imgui.ImVec2(p.x + size - thickness, p.y + size - thickness), imgui.GetColorU32Vec4(col.color), thickness)
            DL:AddLine(imgui.ImVec2(p.x + size - thickness, p.y - size + thickness), imgui.ImVec2(p.x - size + thickness, p.y + size - thickness), imgui.GetColorU32Vec4(col.color), thickness)
        end
    end
    imgui.SetCursorPos(imgui.ImVec2(c.x - size, c.y - size))
    return imgui.InvisibleButton('CLOSEBUTTONBEBRA', imgui.ImVec2(size * 2, size * 2))
end

function imgui.CenterText(text)
    local width = imgui.GetWindowWidth()
    local calc = imgui.CalcTextSize(text)
    imgui.SetCursorPosX( width / 2 - calc.x / 2 )
    imgui.Text(text)
end

function sampev.onSetInterior(interior)
    if interior == 236 and bdmg[0] then
        bnotfonscreen[0] = false
        bnotfinchat[0] = false
        bsoundnotf[0] = false
        brender[0] = false
        btraser[0] = false
        bpc[0] = false
    end
end

function sampev.onCreateGangZone(zoneId, squareStart, squareEnd, color)
    if color == -16776961 then
        mapUsed = true
        kladZone = zoneId
        left = squareStart.x
        up = squareStart.y
        right = squareEnd.x
        down = squareEnd.y
        print('l: ' .. left .. '; u: ' .. up .. '; r: ' .. right .. '; d: ' .. down)
    end
end

function sampev.onGangZoneDestroy(zoneId1)
    if zoneId1 == kladZone then
        if btmr[0] then
            removeGangZone(610)
            addGangZone(610, left, up, right, down, -2130706433)
            zoneActive = true
            sampAddChatMessage(prf .. 'Территория возвращена! Отсчёт кулдауна запущен!', -1)
        end
        timekd = os.date('%X')
        hourkd, minutekd, secundkd = timekd:match('(%d+):(%d+):(%d+)')
        if minutekd + 30 < 60 then
            endkd = hourkd .. ':' .. tonumber(minutekd) + 30 .. ':' .. secundkd
        else
            endkd = hourkd + 1 .. ':' .. tonumber(minutekd) - 60 + 30 .. ':' .. secundkd
        end
        kdcond = true
    end
end

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    wait(100)
    sampRegisterChatCommand("MINEPOC", menu.switch)
    addEventHandler('onScriptTerminate', function(script, quit)
        if script == thisScript() then
            saveCFG()
            remove_markers()
            remove_all()
        end
    end)
    if btmrr[0] then
        sampRegisterChatCommand('zonedel', zonedel)
        sampRegisterChatCommand('zonecopy', zonecopy)
        sampRegisterChatCommand('zonepaste', zonepaste)
        check = true
    end
    if bpc[0] then
        sampRegisterChatCommand('tcopy', tcopy)
        sampRegisterChatCommand('tpaste', tpaste)
        check2 = true
    end
    coords, exact_count = {}, 0
    local fontforrender = renderCreateFont("Arial", int[0], 5)
    local fontforscreen = renderCreateFont("Arial", 50, 5)
    local X, Y = getScreenResolution()
    while true do
        wait(0)
        local timenow = os.date('%X')
        if timenow == endkd then
            sampAddChatMessage(prf..'Кулдаун прошел! Карту можно использовать!', -1)
            kdcond = false
            endkd = 'xx:xx:xx'
        end
        remove_markers()
        if yavdemorgane then
            bnotfonscreen[0] = false
            bnotfinchat[0] = false
            bsoundnotf[0] = false
            brender[0] = false
            btraser[0] = false
        end
        if bpointsonmap[0] then
            local A = { getCharCoordinates(PLAYER_PED) }
            
            for i, B in ipairs(coords) do
                local dist = getDistanceBetweenCoords3d(A[1], A[2], A[3], B[1], B[2], B[3])

                if not fullmap and B[4] == 0 then
                    if pool[i] ~= nil then
                        removeBlip(pool[i])
                        pool[i] = nil
                    end
                    goto skip
                end

                if dist <= 20 and bmarkers[0] then
                    markers[i] = createUser3dMarker(B[1], B[2], B[3] + 1.5, 4)
                end
                if dist <= sliderint1[0] and pool[i] == nil then
                    pool[i] = addBlipForCoord(B[1], B[2], B[3])
                    changeBlipColour(pool[i], finded[i] and blip_color[bcolorint2[0] + 1] or blip_color[bcolorint1[0] + 1])
                elseif dist <= sliderint2[0] and finded[i] == nil then
                    finded[i] = true
                    changeBlipColour(pool[i], blip_color[bcolorint2[0] + 1])
                elseif dist > sliderint1[0] and pool[i] ~= nil then
                    removeBlip(pool[i])
                    pool[i] = nil
                end
                ::skip::
            end
        end
        if bshovel[0] then
            if isKeyJustPressed(keys.VK_O) and isKeyCheckAvailable() then
                sampSendChat("/gun")
            end
        end
        if bnotfonscreen[0] or bsoundnotf[0] or brender[0] or btraser[0] then
            for _, v in pairs(getAllObjects()) do
            local model = getObjectModel(v)
                if model == 2680 or model == 1271 then
                    if bnotfonscreen[0] then
                        renderFontDrawText(fontforscreen, 'Клад где-то {00FF00}рядом!', X/3, Y/4, 0xFF00FF00)
                    end
                    if bsoundnotf[0] then
                        addOneOffSound(0.0, 0.0, 0.0, 1137)
                    end
                end
                if isObjectOnScreen(v) then
                    if model == 2680 or model == 1271 then
                        local _, x, y, z = getObjectCoordinates(v)
                        local x1, y1 = convert3DCoordsToScreen(x,y,z)
                        local x2,y2,z2 = getCharCoordinates(PLAYER_PED)
                        local x10, y10 = convert3DCoordsToScreen(x2,y2,z2)
                        local distance = string.format("%.0f", getDistanceBetweenCoords3d(x, y, z, x2, y2, z2))
                        if bpc[0] and model == 2680 then
                            local _, x, y, z = getObjectCoordinates(v)
                            xforklad, yforklad, zforklad = x, y, z
                        end
                        if brender[0] then
                            renderFontDrawText(fontforrender, 'Клад'..'['..distance..']', x1, y1, colortest1)
                        end
                        if btraser[0] then
                            renderDrawLine(x10, y10, x1, y1, 1.0, colortest2)
                        end
                    end
                end
            end
        end
        if nnint ~= int[0] then
            nnint = int[0]
            fontforrender = renderCreateFont("Arial", nnint, 5)
        end
        if nnint1 ~= combo_int1[0] then
            nnint1 = combo_int1[0]
            bcolorint1[0] = nnint1
            remove_markers()
            remove_all()
        end
        if nnint2 ~= combo_int2[0] then
            nnint2 = combo_int2[0]
            bcolorint2[0] = nnint2
            remove_markers()
            remove_all()
        end
        if menu.state then
            renderFontDrawText(fontforrender, 'Клад'..'['..'distance'..']', 400, 400, colortest1)
            renderDrawLine(450, 450, 450, 500, 1.0, colortest2)
        end
        if bpointsonmap[0] then
            rekey = true
        end
        if not bpointsonmap[0] and rekey then
            remove_all()
            remove_markers()
            rekey = false
        end
    end
end

function sampev.onCreateObject(id, data)
    if data.modelId == 2680 then
        lua_thread.create(function()
            wait(50)
            if bnotfinchat[0] then
                sampAddChatMessage(prf..'Клад где-то рядом!', -1)
            end
            if bpc[0] then
                sampAddChatMessage(prf..'Напишите {8B0000}/tcopy{808080}, чтобы скопировать координаты клада!', -1)
            end
        end)
    end
end

function zonedel()
    if btmrr[0] then
        removeGangZone(610)
        sampAddChatMessage(prf .. 'Прошлая территория была удалена!', -1)
    end
end

function zonecopy()
    if btmrr[0] then
        if mapUsed then
        setClipboardText('/zonepaste l: ' .. left .. '; u: ' .. up .. '; r: ' .. right .. '; d: ' .. down)
        print('/zonepaste l: ' .. left .. '; u: ' .. up .. '; r: ' .. right .. '; d: ' .. down .. ' - скопировано')
        sampAddChatMessage(prf .. 'Скопировано! Отправь это человеку, с которым хочешь поделиться координатами.', -1)
        else
            sampAddChatMessage(prf .. 'Активируй карту кладов, чтобы скопировать координаты.', -1)
        end
    end
end

function tcopy()
    if bpc[0] then
        setClipboardText('/tpaste x: ' .. xforklad .. '; y: ' .. yforklad .. '; z: ' .. zforklad)
        sampAddChatMessage(prf..'Скопировано! Отправь это человеку, с которым хочешь поделиться координатами.', -1)
    end
end

function tpaste(coord)
    if bpc[0] then
        if coord:match('x: (.*); y: (.*); z: (.*)') then
            local x, y, z = coord:match('x: (.*); y: (.*); z: (.*)')
            placeWaypoint(x, y, z)
            setMarker(2, x, y, z, 1, -1)
            sampAddChatMessage(prf .. 'Метка успешно добавлена на твою карту!', -1)
        else
            sampAddChatMessage(prf .. 'Не тот формат! Вставь сюда координаты, которые тебе отправил друг в формате xyz.', -1)
        end
    end
end

function setMarker(type, x, y, z, radius, color)
    deleteCheckpoint(marker)
    removeBlip(checkpoint)
    checkpoint = addBlipForCoord(x, y, z)
    marker = createCheckpoint(type, x, y, z, 1, 1, 1, radius)
    changeBlipColour(checkpoint, color)
    lua_thread.create(function()
    repeat
        wait(0)
        local x1, y1, z1 = getCharCoordinates(PLAYER_PED)
        until getDistanceBetweenCoords3d(x, y, z, x1, y1, z1) < radius or not doesBlipExist(checkpoint)
        deleteCheckpoint(marker)
        removeBlip(checkpoint)
        addOneOffSound(0, 0, 0, 1149)
    end)
end

function zonepaste(coord)
    if btmrr[0] then
        zonepaste = not zonepaste
        if zonepaste then
            if #coord ~= 0 then
                if coord:match('l: (.*); u: (.*); r: (.*); d: (.*)') then
                    pLeft, pUp, pRight, pDown = coord:match('l: (.*); u: (.*); r: (.*); d: (.*)')
                    removeGangZone(610)
                    addGangZone(610, pLeft, pUp, pRight, pDown, -2130706433) -- -1000070000
                    zoneActive = true
                    sampAddChatMessage(prf .. 'Территория была успешно добавлена на твою карту!', -1)
                else
                    sampAddChatMessage(prf .. 'Не тот формат! Вставь сюда координаты, которые тебе отправил друг с картой кладов.', -1)
                end
            else
                sampAddChatMessage(prf .. 'Ты ничего не ввёл! Вставь сюда координаты, которые тебе отправил друг с картой кладов.', -1)
            end
        else
            if zoneActive then
                removeGangZone(610)
                zoneActive = false
                sampAddChatMessage(prf .. 'Территория была удалена. Чтобы вернуть, введи координаты еще раз!', -1)
            else
                sampAddChatMessage(prf .. 'Не тот формат! Вставь сюда координаты, которые тебе отправил друг с картой кладов.', -1)
            end
        end
    end
end

function saveCFG()
    mainini.th.bnotfonscreen = bnotfonscreen[0]
    mainini.th.bnotfinchat = bnotfinchat[0]
    mainini.th.bsoundnotf = bsoundnotf[0]
    mainini.th.brender = brender[0]
    mainini.th.btraser = btraser[0]
    mainini.th.bpointsonmap = bpointsonmap[0]
    mainini.th.bmarkers = bmarkers[0]
    mainini.th.bshovel = bshovel[0]
    mainini.th.btmr = btmr[0]
    mainini.th.btmrr = btmrr[0]
    mainini.th.sliderint1 = sliderint1[0]
    mainini.th.sliderint2 = sliderint2[0]
    mainini.th.int = int[0]
    mainini.th.bcolorint1 = combo_int1[0]
    mainini.th.bcolorint2 = combo_int2[0]
    mainini.th.colortest1 = colortest1
    mainini.th.colortest2 = colortest2
    mainini.th.c3r1 = color3render[0]
    mainini.th.c3r2 = color3render[1]
    mainini.th.c3r3 = color3render[2]
    mainini.th.c3t1 = color3traser[0]
    mainini.th.c3t2 = color3traser[1]
    mainini.th.c3t3 = color3traser[2]
    mainini.th.bpc = bpc[0]
    mainini.th.bdmg = bdmg[0]
    inicfg.save(mainini, 'th8.ini')
end

function cmd_histor(arg)
    renderWindow[0] = not renderWindow[0]
end

function isKeyCheckAvailable()
    if not isSampLoaded() then
        return true
    end
    if not isSampfuncsLoaded() then
        return not sampIsChatInputActive() and not sampIsDialogActive()
    end
    return not sampIsChatInputActive() and not sampIsDialogActive() and not isSampfuncsConsoleActive()
end

function onWindowMessage(msg, wparam, lparam)
    if msg == 0x100 or msg == 0x101 then
        if (wparam == (27)--[[esc]] and (menu.state)) and not isPauseMenuActive() then
                consumeWindowMessage(true, false)
            if msg == 0x101 then
                if menu.state then
                    menu.switch()
                end
            end
        end
    end
    if msg == 0x100 or msg == 0x101 then
        if (wparam == (27)--[[esc]] and (info.state)) and not isPauseMenuActive() then
                consumeWindowMessage(true, false)
            if msg == 0x101 then
                if info.state then
                    info.switch()
                end
            end
        end
    end
end

function imgui.TextColoredRGB(text)
    local style = imgui.GetStyle()
    local colors = style.Colors
    local col = imgui.Col
    
    local designText = function(text__)
        local pos = imgui.GetCursorPos()
        if sampGetChatDisplayMode() == 2 then
            for i = 1, 1 --[[Степень тени]] do
                imgui.SetCursorPos(imgui.ImVec2(pos.x + i, pos.y))
                imgui.TextColored(imgui.ImVec4(0, 0, 0, 1), text__) -- shadow
                imgui.SetCursorPos(imgui.ImVec2(pos.x - i, pos.y))
                imgui.TextColored(imgui.ImVec4(0, 0, 0, 1), text__) -- shadow
                imgui.SetCursorPos(imgui.ImVec2(pos.x, pos.y + i))
                imgui.TextColored(imgui.ImVec4(0, 0, 0, 1), text__) -- shadow
                imgui.SetCursorPos(imgui.ImVec2(pos.x, pos.y - i))
                imgui.TextColored(imgui.ImVec4(0, 0, 0, 1), text__) -- shadow
            end
        end
        imgui.SetCursorPos(pos)
    end
    
    
    
    local text = text:gsub('{(%x%x%x%x%x%x)}', '{%1FF}')

    local color = colors[col.Text]
    local start = 1
    local a, b = text:find('{........}', start)   
    
    while a do
        local t = text:sub(start, a - 1)
        if #t > 0 then
            designText(t)
            imgui.TextColored(color, t)
            imgui.SameLine(nil, 0)
        end

        local clr = text:sub(a + 1, b - 1)
        if clr:upper() == 'STANDART' then color = colors[col.Text]
        else
            clr = tonumber(clr, 16)
            if clr then
                local r = bit.band(bit.rshift(clr, 24), 0xFF)
                local g = bit.band(bit.rshift(clr, 16), 0xFF)
                local b = bit.band(bit.rshift(clr, 8), 0xFF)
                local a = bit.band(clr, 0xFF)
                color = imgui.ImVec4(r / 255, g / 255, b / 255, a / 255)
            end
        end

        start = b + 1
        a, b = text:find('{........}', start)
    end
    imgui.NewLine()
    if #text >= start then
        imgui.SameLine(nil, 0)
        designText(text:sub(start))
        imgui.TextColored(color, text:sub(start))
    end
end

function addGangZone(id, left, up, right, down, color) -- Создание ганг-зоны.
    local bs = raknetNewBitStream()
    raknetBitStreamWriteInt16(bs, id)
    raknetBitStreamWriteFloat(bs, left)
    raknetBitStreamWriteFloat(bs, up)
    raknetBitStreamWriteFloat(bs, right)
    raknetBitStreamWriteFloat(bs, down)
    raknetBitStreamWriteInt32(bs, color)
    raknetEmulRpcReceiveBitStream(108, bs)
    raknetDeleteBitStream(bs)
end


function removeGangZone(id) -- Удаление ганг-зоны по ID
    local bs = raknetNewBitStream()
    raknetBitStreamWriteInt16(bs, id)
    raknetEmulRpcReceiveBitStream(120, bs)
    raknetDeleteBitStream(bs)
end

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    white_style()
    local glyph_ranges = imgui.GetIO().Fonts:GetGlyphRangesCyrillic()
    local path = getFolderPath(0x14) .. '\\trebucbd.ttf'
    local path2 = getFolderPath(0x14) .. '\\agencyr.ttf'
    imgui.GetIO().Fonts:Clear() -- Удаляем стандартный шрифт на 14
    imgui.GetIO().Fonts:AddFontFromFileTTF(path, 15.0, nil, glyph_ranges) -- этот шрифт на 15 будет стандартным
    -- дополнительные шриты:
    font[24] = imgui.GetIO().Fonts:AddFontFromFileTTF(path2, 25.0, nil, glyph_ranges)
    font[25] = imgui.GetIO().Fonts:AddFontFromFileTTF(path, 25.0, nil, glyph_ranges)
    font[15] = imgui.GetIO().Fonts:AddFontFromFileTTF(path, 15.0, nil, glyph_ranges)
    white_style()
end)

local newFrame = imgui.OnFrame(
    function() return menu.alpha > 0.00 end,
    function(self)
        local xsize, ysize = 1000, 500
        local bysize = 310
        local bxsize = 243
        self.HideCursor = not menu.state -- // Курсор будет убираться на моменте, когда окно начинает исчезать
        imgui.PushStyleVarFloat(imgui.StyleVar.Alpha, menu.alpha)
        imgui.SetNextWindowPos(imgui.ImVec2(sizeX / 2, sizeY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin("Main Window", _, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.NoTitleBar)
            imgui.PushFont(font[25])
            imgui.TextColored(imgui.ImVec4(1.00, 0.28, 0.28, 1.00), u8'TREASURE TOOLS', imgui.SameLine())
            imgui.TextColored(imgui.ImVec4(1.00, 1.00, 1.00, 1.00), u8'by histor | Version ', imgui.SameLine())
            imgui.TextColored(imgui.ImVec4(0.00, 1.00, 0.00, 1.00), u8'8.0    ', imgui.SameLine())
            imgui.TextColored(imgui.ImVec4(1.00, 1.00, 1.00, 1.00), u8'Map cooldown: ', imgui.SameLine())
            imgui.TextColored(imgui.ImVec4(0.00, 1.00, 0.00, 1.00), u8(endkd), imgui.SameLine())
            imgui.PopFont()
            imgui.BeginChild(u8"Информация", imgui.ImVec2(xsize-231, 240), true)
                imgui.PushFont(font[25])
                imgui.TextColored(imgui.ImVec4(1.00, 1.00, 1.00, 1.00), u8'Информация', imgui.SameLine())
                imgui.PopFont()
                --{FF0000} - красный
                --{00FF00} - зелёный
                --{FFFFFF} - белый
                imgui.TextColoredRGB(u8'{FF0000} Treasure Tools {FFFFFF}- набор полезных инструментов, который будет полезен для всех кладоискателей {FF0000}Аризоны РП{FFFFFF}.')
                imgui.TextColoredRGB(u8' Функции разделены на {00FF00}3{FFFFFF} категории: "{00FF00}Уведомления{FFFFFF}" | "{00FF00}Маркеры на карте{FFFFFF}" | "{00FF00}Дополнительные функции{FFFFFF}".')
                imgui.TextColoredRGB(u8' {00FF00}Информация{FFFFFF} о функции можно узнать наведя курсор на {FF0000}круглый чекбокс {FFFFFF}функции.')
                imgui.TextColoredRGB(u8' Map cooldown: {00FF00}xx:xx:xx{FFFFFF} - это поле, в котором Вы увидите время окончания {00FF00}кулдауна{FFFFFF} на использование карты кладов.')
                imgui.TextColoredRGB(u8' Клады на Аризоне можно искать с {00FF00}10 уровня {FFFFFF}при наличии {00FF00}лицензии на раскопки{FFFFFF} и {00FF00}лопаты{FFFFFF}.')
                imgui.TextColoredRGB(u8' В {00FF00}хелпере{FFFFFF} есть {FF0000}запрещённые функции{FFFFFF}. {FF0000}Внимательно {FFFFFF}читайте {00FF00}правила{FFFFFF} вашего сервера!')
                imgui.TextColoredRGB(u8' Часть функционала была взята у {00FF00}других авторов{FFFFFF}. Спасибо им{FF0000}<3')
                imgui.TextColoredRGB(u8' Отдельное спасибо парням из {FF0000}Armor ST{FFFFFF}: {00FF00}Armor{FFFFFF}, {00FF00}kjor32{FFFFFF}, {00FF00}ecl1pse{FFFFFF} - {FF0000}вы лучшие)')
                imgui.TextColoredRGB(u8' По любым вопросам обращаться в {00FF00}ВК{FFFFFF}, {00FF00}Дискорд{FFFFFF}, {00FF00}Телеграм{FFFFFF}: {00FF00}vk.com/younghistor{FFFFFF} | {00FF00}histor#8461{FFFFFF} | {00FF00}@younghistor')
            imgui.EndChild()

            imgui.BeginChild(u8"Уведомления", imgui.ImVec2(bxsize, bysize), true)
                imgui.PushFont(font[25])
                imgui.TextColored(imgui.ImVec4(1.00, 1.00, 1.00, 1.00), u8'Уведомления:', imgui.SameLine())
                imgui.PopFont()
                imgui.TodoCheck(u8"1) Уведомление на экране", bnotfonscreen, _, "Функция показывает текст на экране, когда рядом находится возможный клад.")
                imgui.TodoCheck(u8"2) Уведомление в чате", bnotfinchat, _, "Функция отправляет сообщение в чат, когда рядом находится возможный клад.")
                imgui.TodoCheck(u8"3) Звуковое уведомление", bsoundnotf, _, "Функция воспроизводит звук, когда рядом находится возможный клад.")
                imgui.TodoCheck(u8"4) Рендер кладов", brender, _, "Функция показывает место возможного клада, когда он находится рядом.")
                if brender[0] then
                    imgui.Text('       >')
                    imgui.SameLine()
                    imgui.Text(u8'Размер текста рендера:')
                    imgui.Text('       ^')
                    imgui.SameLine()
                    imgui.SliderInt("##рендер кладов", int, 10, 20)
                    imgui.Text('       >')
                    imgui.SameLine()
                    imgui.Text(u8'Цвет текста рендера:')
                    imgui.Text('       ^')
                    imgui.SameLine()
                    if imgui.ColorEdit3(u8'##colorebat1', color3render, imgui.ColorEditFlags.NoLabel) then
                        local clr = join_argb(0, color3render[0] * 255, color3render[1] * 255, color3render[2] * 255)
                        colortest1 = '0xFF'..('%06X'):format(clr)
                    end
                end
                imgui.TodoCheck(u8"5) Трасер", btraser, _, "Функция рисует линию к возможному кладу, когда он находится рядом.")
                if btraser[0] then
                    imgui.Text('       >')
                    imgui.SameLine()
                    imgui.Text(u8'Цвет трасера:')
                    imgui.Text('       ^')
                    imgui.SameLine()
                    if imgui.ColorEdit3(u8'##colorebat2', color3traser, imgui.ColorEditFlags.NoLabel) then
                        local clr = join_argb(0, color3traser[0] * 255, color3traser[1] * 255, color3traser[2] * 255)
                        colortest2 = '0xFF'..('%06X'):format(clr)
                    end
                end
            imgui.EndChild()
            imgui.SameLine()
            imgui.BeginChild(u8"Маркеры на карте", imgui.ImVec2(273, bysize), true)
                imgui.PushFont(font[25])
                imgui.TextColored(imgui.ImVec4(1.00, 1.00, 1.00, 1.00), u8'Маркеры на карте:', imgui.SameLine())
                imgui.TextColored(imgui.ImVec4(0.00, 1.00, 0.00, 1.00), u8(#coords), imgui.SameLine())
                imgui.PopFont()
                imgui.TodoCheck(u8"Позиции кладов:", bpointsonmap, _, "Функция показывает метки спавна кладов на карте.")
                if bpointsonmap[0] then
                    imgui.Text('       >')
                    imgui.SameLine()
                    imgui.Text(u8'Цвет не проверенных меток:')
                    imgui.Text('       ^')
                    imgui.SameLine()
                    imgui.Combo(u8'###1', combo_int1, ImItems, #combo_colors)
                    imgui.Text('       >')
                    imgui.SameLine()
                    imgui.Text(u8'Радиус обычных меток:')
                    imgui.Text('       ^')
                    imgui.SameLine()
                    imgui.SliderInt(u8'~500м', sliderint1, 100, 1000)
                    imgui.Text('       >')
                    imgui.SameLine()
                    imgui.TodoCheck(u8"3D маркеры:", bmarkers, _, "Функция расставляет 3D маркеры в местах спавна кладов.")
                    imgui.Text('       >')
                    imgui.SameLine()
                    imgui.Text(u8'Цвет проверенных меток:')
                    imgui.Text('       ^')
                    imgui.SameLine()
                    imgui.Combo(u8'###2', combo_int2, ImItems, #combo_colors)
                    imgui.Text('       >')
                    imgui.SameLine()
                    imgui.Text(u8'Радиус проверки меток:')
                    imgui.Text('       ^')
                    imgui.SameLine()
                    imgui.SliderInt(u8'~15м', sliderint2, 3, 25)
                end
            imgui.EndChild()
            imgui.SameLine()
            imgui.BeginChild(u8"Доп.функции", imgui.ImVec2(bxsize, bysize), true)
                imgui.PushFont(font[25])
                imgui.TextColored(imgui.ImVec4(1.00, 1.00, 1.00, 1.00), u8'Доп.функции:', imgui.SameLine())
                imgui.PopFont()
                imgui.TodoCheck(u8"1) Бинд лопаты", bshovel, _, "Функция использует команду /gun(-Использовать активный аксессуар) при нажатии клавиши O(eng).")
                imgui.TodoCheck(u8"2) Treasure Map Restore", btmr, _, "Функция восстанавливает зону карты кладов.")
                if imgui.TodoCheck(u8"3) Treasure Map Edit", btmrr, _, "Функция помогает работать с зоной карты кладов. Можно поделиться с другом.\nКоманды:\n/zonecopy - команда копирует координаты зоны карты кладов.\n/zonepaste - команда вставляет зону карты кладов по координатам.\n/zonedel - команда удаляет зону карты кладов.") then
                    if not btmrr[0] and check then
                        sampUnregisterChatCommand('zonedel')
                        sampUnregisterChatCommand('zonecopy')
                        sampUnregisterChatCommand('zonepaste')
                        check = false
                    end
                    if btmrr[0] and not check then
                        sampRegisterChatCommand('zonedel', zonedel)
                        sampRegisterChatCommand('zonecopy', zonecopy)
                        sampRegisterChatCommand('zonepaste', zonepaste)
                        check = true
                    end
                end
                if imgui.TodoCheck(u8"4) Координаты клада", bpc, _, "Функция помогает работать с координатами клада. Можно поделиться с друзьями.\nКоманды:\n/tcopy - команда копирует координаты найденного клада.\n/tpaste - команда ставит метку по координатам.") then
                    if not btmrr[0] and check2 then
                        sampUnregisterChatCommand('tcopy')
                        sampUnregisterChatCommand('tpaste')
                        check2 = false
                    end
                    if btmrr[0] and not check2 then
                        sampRegisterChatCommand('tcopy', tcopy)
                        sampRegisterChatCommand('tpaste', tpaste)
                        check2 = true
                    end
                end
                imgui.TodoCheck(u8"5) Деморган", bdmg, _, "Функция выключает раздел уведомлений, если вы попадаете в деморган.")
                end
            imgui.EndChild())
            
            imgui.BeginChild(u8"Кнопочки", imgui.ImVec2(xsize-231, 50), true)
                
                if imgui.Button(u8'Перезагрузить скрипт', imgui.ImVec2(bxsize-5, 40)) then
                    saveCFG()
                    thisScript():reload()
                end
                imgui.SameLine()
                if imgui.Button(u8'Стандартные настройки', imgui.ImVec2(bxsize+30, 40)) then
                    bnotfonscreen[0] = false
                    bnotfinchat[0] = false
                    bsoundnotf[0] = false
                    brender[0] = false
                    btraser[0] = false
                    bpointsonmap[0] = false
                    bmarkers[0] = false
                    bshovel[0] = false
                    btmr[0] = false
                    sliderint1[0] = 500
                    sliderint2[0] = 15
                    int[0] = 10
                    bcolorint1[0] = 0
                    bcolorint2[0] = 1
                    combo_int1[0] = 0
                    combo_int2[0] = 1
                    colortest1 = 0xFFFFFFFF
                    colortest2 = 0xFFFFFFFF
                    color3render[0] = 1.0
                    color3render[1] = 1.0
                    color3render[2] = 1.0
                    color3traser[0] = 1.0
                    color3traser[1] = 1.0
                    color3traser[2] = 1.0
                    bpc[0] = false
                    saveCFG()
                    sampAddChatMessage(prf..'Стандартные настройки успешно сохранены!', -1)
                end
                imgui.SameLine()
                if imgui.Button(u8'Сохранить настройки', imgui.ImVec2(bxsize-5, 40)) then
                    sampAddChatMessage(prf..'Настройки успешно сохранены!', -1)
                    saveCFG()
                end

            imgui.EndChild()
            imgui.SetCursorPos(imgui.ImVec2(xsize/2+261, 10+8))
            if imgui.CloseButton(10, 3) then
                menu.switch()
            end
        imgui.End()
    end
)


function imgui.Hint(str_id, hint, delay)
    local hovered = imgui.IsItemHovered()
    local animTime = 0.2
    local delay = delay or 0.00
    local show = true

    if not allHints then allHints = {} end
    if not allHints[str_id] then
        allHints[str_id] = {
            status = false,
            timer = 0
        }
    end

    if hovered then
        for k, v in pairs(allHints) do
            if k ~= str_id and os.clock() - v.timer <= animTime  then
                show = false
            end
        end
    end

    if show and allHints[str_id].status ~= hovered then
        allHints[str_id].status = hovered
        allHints[str_id].timer = os.clock() + delay
    end

    if show then
        local between = os.clock() - allHints[str_id].timer
        if between <= animTime then
            local s = function(f)
                return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
            end
            local alpha = hovered and s(between / animTime) or s(1.00 - between / animTime)
            imgui.PushStyleVarFloat(imgui.StyleVar.Alpha, alpha)
            imgui.SetTooltip(hint)
            imgui.PopStyleVar()
        elseif hovered then
            imgui.SetTooltip(hint)
        end
    end
end
 
  • Грустно
Реакции: qdIbp

hanyysh

Новичок
11
6
Теперь работает
Screenshot_566.png

Была лишняя скобка
 

Вложения

  • minepoc clad.lua
    44.7 KB · Просмотры: 3
  • Нравится
Реакции: Krtixikteq