Скачивание на кнопку.

enyag

Известный
Автор темы
345
12
почему качает лишь два первых файла, а остальное нет?
Lua:
script_name('Global Mode Pears Project')
script_version('1')
script_author('enyag')

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local imgui = require 'imgui'
local dlstatus = require('moonloader').download_status
local sampev = require 'lib.samp.events'

local main_window_state = imgui.ImBool(false)


function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
 
    style.WindowPadding = imgui.ImVec2(15, 15)
    style.WindowRounding = 1.5
    style.FramePadding = imgui.ImVec2(5, 5)
    style.FrameRounding = 4.0
    style.ItemSpacing = imgui.ImVec2(12, 8)
    style.ItemInnerSpacing = imgui.ImVec2(8, 6)
    style.IndentSpacing = 25.0
    style.ScrollbarSize = 15.0
    style.ScrollbarRounding = 9.0
    style.GrabMinSize = 5.0
    style.GrabRounding = 3.0
 
    colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
    colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
    colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
    colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
    colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
    colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
    colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
    colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
    colors[clr.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
    colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
    colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
    colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
    colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
    colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
  end
  apply_custom_style()


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    imgui.Process = false

    sampRegisterChatCommand("glp", glp)

    while true do
        wait(0)


    end
end

function glp(arg)
    local sw, sh = getScreenResolution()
    -- center
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(300, 200))

    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
    end

function imgui.OnDrawFrame()
    local sw, sh = getScreenResolution()
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.CondFirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(710, 400), imgui.Cond.FirstUseEver)

    if not main_window_state.v then
        imgui.Process = false
    end

    if main_window_state.v then
        imgui.Begin(u8"Hello", main_window_state, imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoResize)
        if imgui.Button(u8'Чат скрипта', imgui.ImVec2(90, 40)) then
            sampAddChatMessage("Начинаю проверку на библиотеку Broadcaster.", -1)
            if not doesDirectoryExist('moonloader/lib/broadcaster') then createDirectory('moonloader/lib/broadcaster') end
            sampAddChatMessage("Папка библиотеки создана, закачиваю в неё файлы.", -1)
            if not doesFileExist("moonloader/lib/broadcaster/charset.lua") then
                sampAddChatMessage('Файл не найден. Начинаю установку.', -1)
                download_id = downloadUrlToFile('https://drive.google.com/uc?export=download&confirm=no_antivirus&id=1pF4enKPtGxX7qay09rYSROU673CW5RE7'), getWorkingDirectory()..'/lib/broadcaster/charset.lua', function(id, status)
                    sampAddChatMessage('Почти скачал, ещё чуть-чуть.', -1)
                end
            end
            if not doesFileExist("moonloader/lib/broadcaster/encoder.lua") then
                download_id = downloadUrlToFile('https://drive.google.com/uc?export=download&confirm=no_antivirus&id=13sYAHzj_KR3cudTWmOjPVTR5tF-ojgUi'), getWorkingDirectory()..'/lib/broadcaster/encoder.lua', function(id, status)
        end
    end
            if not doesFileExist("moonloader/lib/broadcaster/magic.lua") then
                download_id = downloadUrlToFile("https://drive.google.com/uc?export=download&confirm=no_antivirus&id=13gJr5ncgWOD8vfJhWJZw4qXrptpYV-fG"), getWorkingDirectory().."/lib/broadcaster/magic.lua", function(id, status)
        end
    end
            if not doesFileExist("moonloader/lib/broadcaster/packet.lua") then
                download_id = downloadUrlToFile("https://drive.google.com/uc?export=download&confirm=no_antivirus&id=1jAmpJTNGg1Qmk-l-UtkB_tY7eOF5wA8s"), getWorkingDirectory().."/lib/broadcaster/packet.lua", function(id, status)
        end
    end
            if not doesFileExist("moonloader/lib/broadcaster/session.lua") then
                download_id = downloadUrlToFile("https://drive.google.com/uc?export=download&confirm=no_antivirus&id=1N4bF9lTMtnrWf6rsg3kfYKY_HqrDM_Id"), getWorkingDirectory().."/lib/broadcaster/session.lua", function(id, status)
        end
    end
            if not doesFileExist("moonloader/lib/broadcaster/utils.lua") then
                download_id = downloadUrlToFile("https://drive.google.com/uc?export=download&confirm=no_antivirus&id=1VDujP2_QZSyUoAEZ68a8QHA6_aVuXlXT"), getWorkingDirectory().."/lib/broadcaster/utils.lua", function(id, status)
        end
    end
            if not doesFileExist("moonloader/lib/broadcaster/utils.lua") then
                download_id = downloadUrlToFile("https://drive.google.com/uc?export=download&confirm=no_antivirus&id=1VDujP2_QZSyUoAEZ68a8QHA6_aVuXlXT"), getWorkingDirectory().."/lib/broadcaster/utils.lua", function(id, status)
        end
    end
            if not doesFileExist("moonloader/lib/broadcaster.lua") then
                download_id = downloadUrlToFile("https://drive.google.com/uc?export=download&confirm=no_antivirus&id=1ticHcCQELjIJvUfbQrqsCgXPxVIdp-4M"), getWorkingDirectory().."/lib/broadcaster.lua", function(id, status)
        end
    end
            if not doesFileExist("moonloader/lib/inspect.lua") then
                download_id = downloadUrlToFile("https://drive.google.com/uc?export=download&confirm=no_antivirus&id=1AkdLKWMRoJ7NjfhmIYf54PQtVFzVuFSv"), getWorkingDirectory().."/lib/inspect.lua", function(id, status)
        end
    end
              if not doesFileExist("moonloader/lib/log.lua") then
                download_id = downloadUrlToFile("https://drive.google.com/uc?export=download&confirm=no_antivirus&id=1Kj7V_acF38LqcDnFd0ikxXfk72Skg-Rk"), getWorkingDirectory().."/lib/log.lua", function(id, status)
        end
    end
              if not doesFileExist("moonloader/lib/lua-utf8.dll") then
                download_id = downloadUrlToFile("https://drive.google.com/uc?export=download&confirm=no_antivirus&id=1atBeplKNFR4o8YGTrUvs8ZzU_ZrUGRWO"), getWorkingDirectory().."/lib/lua-utf8.dll", function(id, status)
                sampAddChatMessage("Библиотека установлена, загружаю сам чат.", -1)
        end
    end
            if not doesFileExist("moonloader/chat.lua") then
                download_id = downloadUrlToFile("https://drive.google.com/uc?export=download&confirm=no_antivirus&id=1X4yZgLKThk_PJbN_JPva-PC24Ot0H1FY"), getWorkingDirectory().."/chat.lua", function(id, status)
                    if status == dlstatus.STATUS_ENDDOWNLOADDATA then sampAddChatMessage("Всё установлено, для того чтобы писать в чат, введите /msg [Ваше сообщение]", -1) end
        end
    end
end
    imgui.SameLine()
        if imgui.Button(u8'Функции скрипта', imgui.ImVec2(120, 40)) then
        sampAddChatMessage('sdd', -1)
    end
    imgui.SameLine()
        if imgui.Button(u8'Калькулятор', imgui.ImVec2(100, 40)) then
        sampAddChatMessage('rerer', -1)
    end
    imgui.SameLine()
        if imgui.Button(u8'Установка библиотек', imgui.ImVec2(140, 40)) then
        sampAddChatMessage('gg', -1)
    end
    imgui.SameLine()
        if imgui.Button(u8'Информация о скрипте/Идеи', imgui.ImVec2(180, 40)) then
        sampAddChatMessage('gg', -1)
    end
    imgui.Separator()
        imgui.End()
    end
end