Не работает скрипт.вылетает ошибка

zerodeath

Новичок
Автор темы
1
0
Ошибка:
attempt to index global 'ini' (a nil value)
stack traceback:
код:
Код:
script_name('GANG-HELPER')
script_author("Serhiy_Rubin")

local inicfg, sampev, vkeys = require 'inicfg', require 'lib.samp.events', require 'lib.vkeys'
require 'lib.sampfuncs'
require 'lib.moonloader'
local antiflood = os.clock() * 1000 ; timer = os.clock() ; adid = 21 ; warehouse_status = nil ; warehouse_check = false ; warehouse_delay = 0 ; lss = false
local gunlist = { ['silend_pistol'] = 1, ['deagle'] = 3, ['shotgun'] = 3, ['smg'] = 2, ['m4'] = 3, ['ak47'] = 3, ['rifle'] = 5 }
local coord_resp = {
    {2494.29296875, -1681.8502197266, 12.338387489319}, -- grove
    {2183.3081054688, -1807.8851318359, 12.373405456543}, -- rifa
    {287.72546386719, -141.66345214844, 1006.15625}, -- rifa inta
    {1582.6881103516, -1597.0266113281, 27.475524902344}, -- aztec inta
    {1672.9483642578, -2113.423828125, 12.546875}, -- aztec
    {2647.3308105469, -2029.4759521484, 12.546875}, -- ballas
    {607.73522949219, -147.71377563477, 0}, -- ballas inta
    {2780.3444824219, -1615.7406005859, 9.921875}, -- vagos
    {358.85055541992, 34.617668151855, 0} -- vagos inta
}
local skin = { 41, 114, 115, 116, 56, 105, 106, 107, 269, 270, 271, 195, 102, 103, 104, 190, 108, 109, 110, 226, 173, 174, 175 }

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    repeat wait(0) until sampGetCurrentServerName() ~= 'SA-MP'
    repeat
        wait(0)
        local result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if result then
            score = sampGetPlayerScore(id)
        end
        for i = 1, #skin do
            if isCharModel(PLAYER_PED, skin[i]) then z = 1 end
        end
    until score >= 1 and z ~= nil
    _, my_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    my_nick = sampGetPlayerNickname(my_id)
    ini = inicfg.load({
        Settings = {
            get_guns = 'VK_1',
            warelock_get_guns_warelock = 'VK_3',
            unloading = 'VK_U',
            mat_get_put = 'VK_P',
            gun = 'VK_4',
            inventory = 'VK_M'
        },
        gun = {
            silend_pistol = 0,
            deagle = 0,
            shotgun = 0,
            smg = 0,
            m4 = 0,
            ak47 = 0,
            rifle = 0
        },
        [my_nick] = {
            matov = 0,
            max_matov = 500,
            warelock = false,
            lvl_rank = 6
        }
    })
    inicfg.save(ini)
    while true do
        wait(0)
        doKeyCheck()
    end
end

-- main
function doKeyCheck()
    type(makegun_delay)
    if (not sampIsDialogActive() or (sampGetCurrentDialogType() ~= 1 and sampGetCurrentDialogType() ~= 3)) and not sampIsChatInputActive() then
        if ini.Settings.get_guns ~= "VK_RETURN" and wasKeyPressed(vkeys[ini.Settings.get_guns]) then
            press_time = os.clock() * 1000
        end
        if press_time ~= nil then
            local sc = (os.clock() * 1000 - press_time)
            if isKeyDown(vkeys[ini.Settings.get_guns]) then
                if sc > 800 then
                    warehouse_check = not warehouse_check
                    printStringNow((warehouse_check and '~G~Auto GetGuns: ON' or '~G~Auto GetGuns: OFF'), 1000)
                    press_time = nil
                end
            else
                if sc < 500 then
                    repeat wait(0) until (os.clock() * 1000 - antiflood) > 1000
                    sampSendChat('/get guns')
                    press_time = nil
                end
            end
        end
        if ini.Settings.unloading ~= "VK_RETURN" and wasKeyPressed(vkeys[ini.Settings.unloading]) then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1000
            sampSendChat('/unloading')
        end
        if ini.Settings.warelock_get_guns_warelock ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.warelock_get_guns_warelock]) then
            lua_thread.create(unlock_getguns_lock)
        end
        if ini.Settings.gun ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.gun]) then
            lua_thread.create(makegun)
        end
        if ini.Settings.inventory ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.inventory]) then
            lua_thread.create(inv_check)
        end
        if ini.Settings.mat_get_put ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.mat_get_put]) then
            lss = not lss
            if lss then lua_thread.create(lss_thread) end
            printStringNow((lss and '~G~Auto Loader: ON' or '~G~Auto Loader: OFF'), 1000)
        end
    end
end

function unlock_getguns_lock()
    warehouse_delay = 'warehouse'
    repeat
        wait(0)
        if (os.clock() * 1000 - antiflood) > 1100 then
            if warehouse_delay == 'warehouse' then
                if warehouse_status == nil then
                    warehouse_delay    = 'check warehouse'
                    sampSendChat('/warehouse')
                elseif warehouse_status then
                    warehouse_delay = 'get guns'
                elseif not warehouse_status then
                    warehouse_delay = 'check warelock'
                    sampSendChat('/warelock')
                end
            end
            if warehouse_delay == 'get guns' then
                warehouse_delay = 'check get guns'
                sampSendChat('/get guns')
            end
            if warehouse_delay == 'warelock' then
                warehouse_delay = 'check warelock'
                sampSendChat('/warelock')
            end
        end
    until warehouse_delay == ''
end

function makegun()
    makegun_delay = ''
    local key = { 'silend_pistol', 'deagle', 'shotgun', 'smg', 'm4', 'ak47', 'rifle' }
    local arr = {}
    sellgun = {}
    for k, v in pairs(ini.gun) do
        if v > 0 then
            arr[#arr + 1] = { gun = k, pt = v }
        end
    end
    for i = #arr, 1, -1 do
        sellgun[#sellgun + 1] = { gun = arr[i].gun, pt = arr[i].pt }
    end
    repeat
        wait(0)
        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
        if #sellgun > 0 then
            local gun_name = sellgun[#sellgun].gun
            local pt = sellgun[#sellgun].pt
            local can = ini[my_nick].matov / gunlist[gun_name]
            if pt <= can then
                makegun_delay = '/gun '..gun_name..' '..pt
                sampSendChat(makegun_delay)
                repeat wait(0) until type(makegun_delay) == 'boolean'
                if makegun_delay then sellgun[#sellgun].pt = sellgun[#sellgun].pt - pt end
                if sellgun[#sellgun].pt == nil or sellgun[#sellgun].pt == 0 then sellgun[#sellgun] = nil end
            else
                if can <= 0 then
                    sampAddChatMessage("Ошибка. Не хватает материалов.", 0xffcecece)
                    sellgun = {}
                else
                    makegun_delay = '/gun '..gun_name..' '..can - 1
                    sampSendChat(makegun_delay)
                    sellgun = {}
                end
            end
        end
    until #sellgun == 0
end

function inv_check()
    inv_delay = ''
    repeat wait(0)
        if inv_delay == '' then
            inv_delay = 'send'
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            sampSendChat('/inventory')
        end
    until inv_delay == nil
end

function lss_thread()
    lss_delay = 'get'
    repeat wait(0)
        if lss_delay == 'get' then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            lss_delay = 'get1'
            sampSendChat('/mat get')
        end
        if lss_delay == 'put' then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            lss_delay = 'put1'
            sampSendChat('/mat put')
        end
    until lss_delay == nil
    lss = false
end

-- HOOK

function sampev.onSendChat(message) antiflood = os.clock() * 1000 end
function sampev.onSendCommand(cmd) antiflood = os.clock() * 1000
    if cmd:lower() == "/gh" then
        lua_thread.create(function()
            Dialog()
            start_dialog(dialog[1])
        end)
        return false
    end
    if cmd:lower():find("%/invite (%d+) (%d+)") then
        invID, invRank = cmd:lower():match("%/invite (%d+) (%d+)")
        return { '/invite '..invID }
    end
end

function sampev.onServerMessage(color, message)
    if message:find('Вы не на военном складе') or message:find('Склад военных пуст') or message:find('Необходимо находиться у фургона') or message:find('Фургон полный') then
        if lss_delay ~= nil then
            lss_delay = nil
            printStringNow('~G~Auto Loader: OFF', 2000)
        end
    end
    if message:find('У вас нет материалов с собой') or message:find('Вы уронили ящик') then
        if lss_delay == 'put1' then
            lss_delay = 'get'
        end
    end
    if message:find('У вас на руках уже есть материалы') then
        if lss_delay == 'get1' then
            lss_delay = 'put'
        end
    end
    if message:find('Вы взяли несколько комплектов, положите их в фургон') and lss_delay == 'get1' then lss_delay = 'put' end
    if message:find('Вы положили ящик в фургон. Материалов в фургоне (%d+)/(%d+)') and lss_delay == 'put1' then
        local S1, S2 = message:match('Вы положили ящик в фургон. Материалов в фургоне (%d+)/(%d+)')
        if S1 == S2 then
            lss_delay = nil
            printStringNow('~G~Auto Loader: OFF', 2000)
        else
            lss_delay = 'get'
        end
    end
    if string.find(message, " %(%( Остаток: (%d+) материалов %)%)") then
        ini[my_nick].matov = tonumber(string.match(message, " %(%( Остаток: (%d+) материалов %)%)"))
        inicfg.save(ini)
        makegun_delay = true
    end
    if message == ' У вас недостаточно материалов' or message:find('Необходимо находиться на своей территории')  then
        if sellgun ~= nil and #sellgun > 0 then
            makegun_delay = false
            sellgun = {}
        end
    end
    if string.find(message, " У вас (%d+)/(%d+) материалов с собой") then
        local S1, S2 = string.match(message, " У вас (%d+)/(%d+) материалов с собой")
        ini[my_nick].matov = tonumber(S1) ; ini[my_nick].max_matov = tonumber(S2)
        inicfg.save(ini)
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
        send_auto_getGuns_warehose = nil
    end
    if string.find(message, " (.*) забрал%(а%) у (.*) материалы") or (message:find('выбросил') and message:find('Материалы')) then
        local result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if string.find(message, sampGetPlayerNickname(id)) then ini[my_nick].matov = 0 inicfg.save(ini) end
    end
    if message == " Вы ограбили дом! Наворованный металл можно сдать около порта. (( /gps >> Прием металла ))" or message == " Провал. Сработала сигнализация" then
        ini[my_nick].matov = ini[my_nick].matov - 50
        inicfg.save(ini)
    end
    if message:find('Патронов должно быть от 1') then
        sellgun = {}
    end
    if message == ' Не флуди!' then
        if type(warehouse_delay) == 'string' and warehouse_delay:find('check') then
            warehouse_delay = warehouse_delay:gsub('check ', '')
        end
        if type(makegun_delay) == 'string' and makegun_delay:find('gun') then
            makegun_delay = false
        end
        if lss_delay ~= nil then
            lss_delay = lss_delay:gsub('1', '')
        end
        if inv_delay == 'giverank1' then
            inv_delay = 'giverank'
        end
        if warehouse_chekay == 2 then
            warehouse_chekay = 1
        end
    end
    if message == ' Вам недоступна эта функция' or message == " Ранг должен быть выше" then
        warehouse_delay = ''
        market_gun = false
    end
    if message == ' Необходимо находиться на своей базе' then
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
    end
    if message:find('На складе недостаточно материалов') then
        market_gun = false
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
    end
    if string.find(message, " (.*) закрыл%(а%) склад с оружием") then
        warehouse_status = false
        send_auto_getGuns_warehose = nil
        if warehouse_delay == 'check warelock' then
            warehouse_delay = ''
        end
    end
    if string.find(message, " (.*) открыл%(а%) склад с оружием") then
        warehouse_status = true
        if warehouse_delay == 'check warelock' then
            warehouse_delay = 'get guns'
        end
        if warehouse_check then
            lua_thread.create(function()
                for k,v in pairs(coord_resp) do
                    local dist = math.floor(getDistanceBetweenCoords3d(v[1], v[2], v[3], getCharCoordinates(playerPed)))
                    if dist <= 100.0 then
                        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
                        sampSendChat('/get guns')
                        break
                    end
                end
            end)
        end
    end
    if string.find(message, " Склад ") and (string.find(message, "00AB06") or string.find(message, "C42100")) then
        if string.find(message, "00AB06") then
            warehouse_status = true
            if warehouse_delay == 'check warehouse' then
                warehouse_delay = 'get guns'
            end
        end
        if string.find(message, "C42100") then
            warehouse_status = false
            if warehouse_delay == 'check warehouse' then
                warehouse_delay = 'warelock'
            end
        end
        warehouse_check = false
        if warehouse_chekay == 2 then
            return false
        end
    end
    if message:find(' (%d+)/(%d+) Матов | (%d+)/(%d+) Аптечек') then
        local s1, s2, s3, s4 = message:match(' (%d+)/(%d+) Матов | (%d+)/(%d+) Аптечек')
        if warehouse_chekay == 2 then
            warehouse_chekay = nil
            printStringNow((ini[my_nick].matov > 0 and '~W~Mats: ' or '~R~Mats: ')..ini[my_nick].matov..'/'..ini[my_nick].max_matov..'~N~~W~Warehouse '..s1..'/'..s2, 7000)
            return false
        end
    end
    if message:find(' Вы приняли .+ в') and invID ~= nil and invRank ~= nil then
        if invRank ~= nil then
            lua_thread.create(function()
                inv_delay = 'giverank'
                repeat wait(0)
                    if inv_delay == 'giverank' then
                        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
                        local lvl = sampGetPlayerScore(invID)
                        if lvl < ini[my_nick].lvl_rank and invRank >= 7 then
                            invRank = 6
                        end
                        inv_delay = 'giverank1'
                        sampSendChat('/giverank '..invID..' '..invRank)
                    end
                until invRank == nil
            end)
        end
    end
    if message:find(' Вы повысили/понизили .+ до %d+ ранга') or message == ' Ошибка. Ранг игрока выше или равен вашему' or message:find('Вам недоступна эта функция!') then
        invRank = nil
        invID = nil
    end
    if message == ' Необходимо находиться рядом друг с другом!' then
        invRank = nil
        invID = nil
    end
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if string.find(title, "Карманы") and style == 4 then
        local array = split(text, '\n')
        for k, string in pairs(array) do
            if string.find(string, "Материалы") then
                ini[my_nick].matov = tonumber(string.match(string, "Материалы.(%d+) / %d+"))
                ini[my_nick].max_matov = tonumber(string.match(string, "Материалы.%d+ / (%d+)"))
                inicfg.save(ini)
            end
        end
        if not string.find(text, "Материалы") then ini[my_nick].matov = 0 inicfg.save(ini) end
        if inv_delay ~= nil and inv_delay == 'send' then
            inv_delay = nil
            warehouse_chekay = true
            lua_thread.create(function()
                warehouse_chekay = 1
                repeat wait(0)
                    if (os.clock() * 1000 - antiflood) > 1100 then
                        if warehouse_chekay == 1 then
                            warehouse_chekay = 2
                            sampSendChat('/warehouse')
                        end
                    end
                until warehouse_chekay == nil
            end)
            return false
        end
    end
end

function sampev.onSendDialogResponse(dialogId, button, listboxId, input)

end


-- Dialog
function Dialog()
dialog = {
    {
        settings = {title = "GANG-HELPER" ,style = 4 ,btn1 = "Далее" ,btn2 = "Закрыть" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            {
                title = "Взятие материалов со склада\t Key: "..ini.Settings.get_guns:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('get_guns')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Проверить материалы\t Key: "..ini.Settings.inventory:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('inventory')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Открыть склад, взять маты, закрыть\t Key: "..ini.Settings.warelock_get_guns_warelock:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('warelock_get_guns_warelock')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Разгрузить фуру\t Key: "..ini.Settings.unloading:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('unloading')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Загрузка ящиков\t Key: "..ini.Settings.mat_get_put:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('mat_get_put')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Сделать оружие из лички\t Key: "..ini.Settings.gun:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('gun')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = " \t ",
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[(button == 0 and 1 or 2)]
                    end
                end
            },
            {
                title = "Минимальный LVL для 7 ранга\t"..ini[my_nick].lvl_rank..' LVL',
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[4]
                    end
                end
            },
            {
                title = "Список оружия которое нужно делать\t",
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[2]
                    end
                end
            },
            {
                title = "Описание скрипта\t",
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[6]
                    end
                end
            },
        },
    },
    {
        settings = {title = "GUN MARKET" ,style = 4 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = true},
        {
            {
                title = "Materials\t"..materials()..'/'..ini[my_nick].max_matov,
                click = function(button, list, input , outs)
                    return dialog[(button == 0 and 1 or 2)]
                end
            },
            {
                title = "Silend Pistol\t"..ini.gun.silend_pistol..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Deagle\t"..ini.gun.deagle..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Shotgun\t"..ini.gun.shotgun..' pt.',
                click = function(button, list, input , outs)
                   return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "SMG\t"..ini.gun.smg..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "M4\t"..ini.gun.m4..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "AK-47\t"..ini.gun.ak47..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Rifle\t"..ini.gun.rifle..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Описание функции.\t",
                click = function(button, list, input , outs)
                    return (button == 1 and dialog[5] or dialog[1])
                end
            },
        }
    },
    {
       settings = {title = "GUN PT" ,style = 1 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = "Введите количество патрон.\nВпишите 0 если вам не нужно это оружие.",
            {
                click = function(button, list, input , outs)
                    if button == 0 then
                        return dialog[2]
                    else
                        if input:find('%d+') then
                            local S1 = ini.gun[market_gun_name]
                            ini.gun[market_gun_name] = tonumber(input:match('(%d+)'))
                            if not materials(1) then
                                ini.gun[market_gun_name] = S1
                                local mat = math.ceil((ini[my_nick].max_matov - materials()) / gunlist[market_gun_name])
                                if mat <= 0 then mat = 0 end
                                sampAddChatMessage("Ошибка. Вы привысили лимит материалов. Доступно: "..mat..' патрон.' , 0xffcecece)
                            end
                            inicfg.save(ini)
                            Dialog()
                            return dialog[2]
                        else
                            sampAddChatMessage("Ошибка. Введите кол-во патрон.", 0xffcecece)
                            return dialog[3]
                        end
                    end
                end
            }
        }
    },
    {
       settings = {title = "RANK INVITE" ,style = 1 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = "В скрипте есть функция повышения игрока сразу после принятия > /invite [ID] [Rank]\nДля того чтобы не проверять LVL игрока - укажите минимальный LVL для 7 ранга.\nЕсли выдаваемый ранг будет выше 6, а уровень будет не соответствовать, тогда игроку будет выдан 6 ранг.",
            {
                click = function(button, list, input , outs)
                    if button == 0 then
                        return dialog[1]
                    else
                        if input:find('%d+') then
                            local lvl = tonumber(input:match('(%d+)'))
                            if lvl > 0 then
                                ini[my_nick].lvl_rank = lvl
                            else
                                sampAddChatMessage("Ошибка. Введите число от 1.", 0xffcecece)
                                return dialog[4]
                            end
                            inicfg.save(ini)
                            Dialog()
                            return dialog[1]
                        else
                            sampAddChatMessage("Ошибка. Введите число от 1.", 0xffcecece)
                            return dialog[4]
                        end
                    end
                end
            }
        }
    },
    {
       settings = {title = "README MARKET" ,style = 0 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = "Функция для использования лички.\nПо нажатию клавиши делает оружие которое вы указали при настройке.\nМожно сделать столько патрон - на сколько хватает лички.\n\nВ первой строке написано на сколько использован лимит.\nПри превышении лимита вам напишет допустимое кол-во патрон.",
            {
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[5]
                    else
                        return dialog[2]
                    end
                end
            }
        }
    },
    {
       settings = {title = "Страница 1" ,style = 0 ,btn1 = "Страница 2" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = '1. Взятие материалов со склада\n- Первый вариант вы просто нажимаете кнопку - он берет маты со склада.\n- Второй вариант вы зажимаете кнопку на секунду - включается взятие матов сразу после открытия склада.\nБудет работать пока не релогнитесь или не отключите таким же способом.\n\n2. Проверить материалы и склад\nПросто проверяет inventory/warehouse и показывает на экране.\n\n3. Открыть склад, взять маты, закрыть\nЕсли скрипту не известен статус склада - он проверяет по /warehouse.\nЕсли склад закрыт - открывает его и берет маты, после закрывает.\nЕсли склад открыт - берет маты и закрывает склад.\n\n4. Разгрузить фуру\nПросто бинд на /unloading',
            {
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[7]
                    else
                        return dialog[1]
                    end
                end
            }
        }
    },
    {
       settings = {title = "README" ,style = 0 ,btn1 = "Понятно" ,btn2 = "Страница 1" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = '5. Сделать оружие из лички\nНиже в меню есть Список оружия которое нужно делать, там указываете кол-во патрон под нужный вам тип оружия.\nНельзя превышать максимальное значение вашей лички.\nЕсли лички не хватает, он сделает столько патрон - на сколько хватит материалов.\n\n6. Повышение после инвайта\nДоработана команда инвайта, после принятия игрока скрипт может его повысить.\nТолько если после ID  вы укажите ранг на который нужно повысить.\nПример: /invite [ID] [Rank]\nТак же в настройках есть мин. лвл для 7 ранга.\nЕсли вы принимаете игрока на 7+ ранг, а у него ЛВЛ меньше требуемого - выдаст 6 ранг.',
            {
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[7]
                    else
                        return dialog[6]
                    end
                end
            }
        }
    },
}
end

function MarketFunc(button, list, input , outs)
    if button == 0 then
        return dialog[2]
    else
        local key = { 'silend_pistol', 'deagle', 'shotgun', 'smg', 'm4', 'ak47', 'rifle' }
        for i = 1, 7 do
            if i == list then
                if key[list] ~= nil then
                    market_gun_name = key[list]
                    return 3
                else
                    sampAddChatMessage("Ошибка. Что то пошло не так.", 0xffcecece)
                    return 0
                end
            end
        end
    end
end

function materials(is)
    local mats = 0
    for k,v in pairs(ini.gun) do
        if v > 0 then
            mats = mats + (v * gunlist[k])
        end
    end
    if is ~= nil then
        if ini[my_nick].max_matov < mats then
            return false
        else
            return true
        end
    else
        return mats
    end
end

function SetKey(keys)
    wait(300)
    sampAddChatMessage('Нажмите на нужную Вам клавишу! Чтобы отключить вообще: нажмите Enter', -1)
    local key = ""
    repeat
        wait(0)
        for k, v in pairs(vkeys) do
            if wasKeyPressed(v) and k ~= "VK_ESCAPE" then
                key = k
            end
        end
    until key ~= ""
    ini.Settings[keys] = key
    inicfg.save(ini)
    wait(300)
end

function ON_OFF(bool)
    return (bool and '{45d900}ON' or '{ff0000}OFF')
end

-- Function Dialog
function start_dialog(menu)
    function _dialog(menu, id,  outs)
        sampShowDialog(id, menu.settings.title, tbl_split(menu.settings.style, menu, menu.settings.forward ,menu.settings.backwards ,menu.settings.score), menu.settings.btn1, (menu.settings.btn2 ~= nil and menu.settings.btn2 or _), menu.settings.style)
            repeat
                wait(0)
                local result, button, list, input = sampHasDialogRespond(id)
                if result then
                    local out, outs = menu[((menu.settings.style == 0 or menu.settings.style == 1 or menu.settings.style == 3) and 1 or ((list + 1) > #menu[1] and 2 or 1))][((menu.settings.style == 0 or menu.settings.style == 1 or menu.settings.style == 3) and 1 or ((list + 1) > #menu[1] and (list - #menu[1]) + 1  or list + 1))].click(button, list, input, outs)
                    if type(out) == "table" then
                        return _dialog(out, id - 1, outs)
                    elseif type(out) == "boolean" then
                        if not out then
                            return out
                        end
                            return _dialog(menu, id, outs)
                    end
                end
            until result
    end

    function tbl_split(style, tbl, forward ,backwards ,score)
        if style == 2 or style == 4 or style == 5 then
            text = (style == 5 and tbl[1].text.."\n" or "")
            for i, val in ipairs(tbl[1]) do
                text = text..""..forward..""..(score and "["..i.."]{ffffff} " or "")..""..val.title..""..backwards
            end
            if tbl[2] ~= nil then
                for _, val in ipairs(tbl[2]) do
                    text = text..""..forward..""..val.title..""..backwards
                end
            end
            return text
        end
        return tbl[1].text
    end

    return _dialog(menu, 1337, outs)
end


--- Function split
function split(str, delim, plain)
    local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]]
    repeat
        local npos, epos = string.find(str, delim, pos, plain)
        table.insert(tokens, string.sub(str, pos, npos and npos - 1))
        pos = epos and epos + 1
    until not pos
    return tokens
end

function split(str, delim, plain)
    local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]]
    repeat
        local npos, epos = string.find(str, delim, pos, plain)
        table.insert(tokens, string.sub(str, pos, npos and npos - 1))
        pos = epos and epos + 1
    until not pos
    return tokens
end
[22:58:04.536600] (system) Session started.
[22:58:04.574600] (debug) Module handle: 5FCE0000

MoonLoader v.026.5-beta loaded.
Developers: FYP, hnnssy, EvgeN 1137

Copyright (c) 2016, BlastHack Team
https://www.blast.hk/moonloader/

[22:58:04.574600] (info) Working directory: D:\игры\GTA\moonloader
[22:58:04.574600] (debug) FP Control: 0009001F
[22:58:04.575600] (debug) Game: GTA SA 1.0.0.0 US
[22:58:04.575600] (system) Installing pre-game hooks...
[22:58:04.597600] (system) Hooks installed.
[22:58:08.495600] (debug) Initializing opcode handler table
[22:58:08.495600] (debug) package.path = D:\игры\GTA\moonloader\lib\?.lua;D:\игры\GTA\moonloader\lib\?\init.lua;D:\игры\GTA\moonloader\?.lua;D:\игры\GTA\moonloader\?\init.lua;.\?.lua;D:\игры\GTA\moonloader\lib\?.luac;D:\игры\GTA\moonloader\lib\?\init.luac;D:\игры\GTA\moonloader\?.luac;D:\игры\GTA\moonloader\?\init.luac;.\?.luac
[22:58:08.495600] (debug) package.cpath = D:\игры\GTA\moonloader\lib\?.dll;
[22:58:08.496600] (system) Loading script 'D:\игры\GTA\moonloader\AutoLomka by VRush.lua'...
[22:58:08.496600] (debug) New script: 01A19E24
[22:58:08.644600] (system) AutoLomka by VRush.lua: Loaded successfully.
[22:58:08.644600] (system) Loading script 'D:\игры\GTA\moonloader\AutoReboot.lua'...
[22:58:08.644600] (debug) New script: 01A22E84
[22:58:08.657600] (system) ML-AutoReboot: Loaded successfully.
[22:58:08.658600] (system) Loading script 'D:\игры\GTA\moonloader\check-moonloader-updates.lua'...
[22:58:08.658600] (debug) New script: 01A2300C
[22:58:08.690600] (system) Check MoonLoader Updates: Loaded successfully.
[22:58:08.690600] (system) Loading script 'D:\игры\GTA\moonloader\clickwarp.lua'...
[22:58:08.690600] (debug) New script: 01A23194
[22:58:08.705600] (system) Click Warp: Loaded successfully.
[22:58:08.705600] (system) Loading script 'D:\игры\GTA\moonloader\DoubleJump.lua'...
[22:58:08.706600] (debug) New script: 01A2331C
[22:58:08.719600] (system) {FFFFFF}DoubleJump{FFD700}bySUTTIEV: Loaded successfully.
[22:58:08.719600] (system) Loading script 'D:\игры\GTA\moonloader\GANG-HELPER.lua'...
[22:58:08.719600] (debug) New script: 01A31D74
[22:58:08.739600] (system) GANG-HELPER: Loaded successfully.
[22:58:08.740600] (system) Loading script 'D:\игры\GTA\moonloader\NuboTP.lua'...
[22:58:08.740600] (debug) New script: 01A32EFC
[22:58:08.744600] (system) NuboTP.lua: Loaded successfully.
[22:58:08.744600] (system) Loading script 'D:\игры\GTA\moonloader\reload_all.lua'...
[22:58:08.744600] (debug) New script: 01A33884
[22:58:08.754600] (system) ML-ReloadAll: Loaded successfully.
[22:58:08.755600] (system) Loading script 'D:\игры\GTA\moonloader\SF Integration.lua'...
[22:58:08.755600] (debug) New script: 01A34A0C
[22:58:08.761600] (system) SF Integration: Loaded successfully.
[22:58:08.761600] (system) Loading script 'D:\игры\GTA\moonloader\walk.luac'...
[22:58:08.761600] (debug) New script: 01A34B94
[22:58:08.764600] (system) Walk: Loaded successfully.
[22:58:14.981600] (system) Installing post-load hooks...
[22:58:14.985600] (system) Hooks installed.
[22:58:20.823600] (script) Walk: {F1C232}Создатель скрипта 00DD00 {FFFFFF}& {F1C232}NN
[22:58:59.389600] (error) GANG-HELPER: D:\игры\GTA\moonloader\GANG-HELPER.lua:432: attempt to index global 'ini' (a nil value)
stack traceback:
D:\игры\GTA\moonloader\GANG-HELPER.lua: in function 'Dialog'
D:\игры\GTA\moonloader\GANG-HELPER.lua:216: in function <D:\игры\GTA\moonloader\GANG-HELPER.lua:215>
stack traceback:
[C]: in function 'create'
D:\игры\GTA\moonloader\GANG-HELPER.lua:215: in function 'callback'
D:\игры\GTA\moonloader\lib\samp\events\core.lua:79: in function <D:\игры\GTA\moonloader\lib\samp\events\core.lua:53>
[22:58:59.390600] (error) GANG-HELPER: Script died due to an error. (01A31D74)
 
Последнее редактирование:
Решение
сам ты

я барибал

я бы лучше переписал код, под +- оптимальную норму
сейчас посмотрим что можно сделать


ну вообщем у тебя, Посмотреть вложение 192380
все inicfg.(функция)(ini,'и отсутсвует название.ini'), у тебя можно сказать не идеть сохранение во всем скрипте
Чо можно и без этого будет название NameScript.lua.ini

Ноу нейм 😂

Ошибка:
attempt to index global 'ini' (a nil value)
stack traceback:
код:
Код:
script_name('GANG-HELPER')
script_author("Serhiy_Rubin")

local inicfg, sampev, vkeys = require 'inicfg', require 'lib.samp.events', require 'lib.vkeys'
require 'lib.sampfuncs'
require 'lib.moonloader'
local antiflood = os.clock() * 1000 ; timer = os.clock() ; adid =...

qdIbp

Автор темы
Проверенный
1,383
1,139
Ну так ини = нил, создай конфиг

Куда пропали @sdfy и еще чел q чето там которые помогали новичкам

@qdIbp вот он
сам ты
и еще чел q чето там
я барибал
Ошибка:
attempt to index global 'ini' (a nil value)
stack traceback:
код:
Код:
script_name('GANG-HELPER')
script_author("Serhiy_Rubin")

local inicfg, sampev, vkeys = require 'inicfg', require 'lib.samp.events', require 'lib.vkeys'
require 'lib.sampfuncs'
require 'lib.moonloader'
local antiflood = os.clock() * 1000 ; timer = os.clock() ; adid = 21 ; warehouse_status = nil ; warehouse_check = false ; warehouse_delay = 0 ; lss = false
local gunlist = { ['silend_pistol'] = 1, ['deagle'] = 3, ['shotgun'] = 3, ['smg'] = 2, ['m4'] = 3, ['ak47'] = 3, ['rifle'] = 5 }
local coord_resp = {
    {2494.29296875, -1681.8502197266, 12.338387489319}, -- grove
    {2183.3081054688, -1807.8851318359, 12.373405456543}, -- rifa
    {287.72546386719, -141.66345214844, 1006.15625}, -- rifa inta
    {1582.6881103516, -1597.0266113281, 27.475524902344}, -- aztec inta
    {1672.9483642578, -2113.423828125, 12.546875}, -- aztec
    {2647.3308105469, -2029.4759521484, 12.546875}, -- ballas
    {607.73522949219, -147.71377563477, 0}, -- ballas inta
    {2780.3444824219, -1615.7406005859, 9.921875}, -- vagos
    {358.85055541992, 34.617668151855, 0} -- vagos inta
}
local skin = { 41, 114, 115, 116, 56, 105, 106, 107, 269, 270, 271, 195, 102, 103, 104, 190, 108, 109, 110, 226, 173, 174, 175 }

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    repeat wait(0) until sampGetCurrentServerName() ~= 'SA-MP'
    repeat
        wait(0)
        local result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if result then
            score = sampGetPlayerScore(id)
        end
        for i = 1, #skin do
            if isCharModel(PLAYER_PED, skin[i]) then z = 1 end
        end
    until score >= 1 and z ~= nil
    _, my_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    my_nick = sampGetPlayerNickname(my_id)
    ini = inicfg.load({
        Settings = {
            get_guns = 'VK_1',
            warelock_get_guns_warelock = 'VK_3',
            unloading = 'VK_U',
            mat_get_put = 'VK_P',
            gun = 'VK_4',
            inventory = 'VK_M'
        },
        gun = {
            silend_pistol = 0,
            deagle = 0,
            shotgun = 0,
            smg = 0,
            m4 = 0,
            ak47 = 0,
            rifle = 0
        },
        [my_nick] = {
            matov = 0,
            max_matov = 500,
            warelock = false,
            lvl_rank = 6
        }
    })
    inicfg.save(ini)
    while true do
        wait(0)
        doKeyCheck()
    end
end

-- main
function doKeyCheck()
    type(makegun_delay)
    if (not sampIsDialogActive() or (sampGetCurrentDialogType() ~= 1 and sampGetCurrentDialogType() ~= 3)) and not sampIsChatInputActive() then
        if ini.Settings.get_guns ~= "VK_RETURN" and wasKeyPressed(vkeys[ini.Settings.get_guns]) then
            press_time = os.clock() * 1000
        end
        if press_time ~= nil then
            local sc = (os.clock() * 1000 - press_time)
            if isKeyDown(vkeys[ini.Settings.get_guns]) then
                if sc > 800 then
                    warehouse_check = not warehouse_check
                    printStringNow((warehouse_check and '~G~Auto GetGuns: ON' or '~G~Auto GetGuns: OFF'), 1000)
                    press_time = nil
                end
            else
                if sc < 500 then
                    repeat wait(0) until (os.clock() * 1000 - antiflood) > 1000
                    sampSendChat('/get guns')
                    press_time = nil
                end
            end
        end
        if ini.Settings.unloading ~= "VK_RETURN" and wasKeyPressed(vkeys[ini.Settings.unloading]) then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1000
            sampSendChat('/unloading')
        end
        if ini.Settings.warelock_get_guns_warelock ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.warelock_get_guns_warelock]) then
            lua_thread.create(unlock_getguns_lock)
        end
        if ini.Settings.gun ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.gun]) then
            lua_thread.create(makegun)
        end
        if ini.Settings.inventory ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.inventory]) then
            lua_thread.create(inv_check)
        end
        if ini.Settings.mat_get_put ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.mat_get_put]) then
            lss = not lss
            if lss then lua_thread.create(lss_thread) end
            printStringNow((lss and '~G~Auto Loader: ON' or '~G~Auto Loader: OFF'), 1000)
        end
    end
end

function unlock_getguns_lock()
    warehouse_delay = 'warehouse'
    repeat
        wait(0)
        if (os.clock() * 1000 - antiflood) > 1100 then
            if warehouse_delay == 'warehouse' then
                if warehouse_status == nil then
                    warehouse_delay    = 'check warehouse'
                    sampSendChat('/warehouse')
                elseif warehouse_status then
                    warehouse_delay = 'get guns'
                elseif not warehouse_status then
                    warehouse_delay = 'check warelock'
                    sampSendChat('/warelock')
                end
            end
            if warehouse_delay == 'get guns' then
                warehouse_delay = 'check get guns'
                sampSendChat('/get guns')
            end
            if warehouse_delay == 'warelock' then
                warehouse_delay = 'check warelock'
                sampSendChat('/warelock')
            end
        end
    until warehouse_delay == ''
end

function makegun()
    makegun_delay = ''
    local key = { 'silend_pistol', 'deagle', 'shotgun', 'smg', 'm4', 'ak47', 'rifle' }
    local arr = {}
    sellgun = {}
    for k, v in pairs(ini.gun) do
        if v > 0 then
            arr[#arr + 1] = { gun = k, pt = v }
        end
    end
    for i = #arr, 1, -1 do
        sellgun[#sellgun + 1] = { gun = arr[i].gun, pt = arr[i].pt }
    end
    repeat
        wait(0)
        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
        if #sellgun > 0 then
            local gun_name = sellgun[#sellgun].gun
            local pt = sellgun[#sellgun].pt
            local can = ini[my_nick].matov / gunlist[gun_name]
            if pt <= can then
                makegun_delay = '/gun '..gun_name..' '..pt
                sampSendChat(makegun_delay)
                repeat wait(0) until type(makegun_delay) == 'boolean'
                if makegun_delay then sellgun[#sellgun].pt = sellgun[#sellgun].pt - pt end
                if sellgun[#sellgun].pt == nil or sellgun[#sellgun].pt == 0 then sellgun[#sellgun] = nil end
            else
                if can <= 0 then
                    sampAddChatMessage("Ошибка. Не хватает материалов.", 0xffcecece)
                    sellgun = {}
                else
                    makegun_delay = '/gun '..gun_name..' '..can - 1
                    sampSendChat(makegun_delay)
                    sellgun = {}
                end
            end
        end
    until #sellgun == 0
end

function inv_check()
    inv_delay = ''
    repeat wait(0)
        if inv_delay == '' then
            inv_delay = 'send'
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            sampSendChat('/inventory')
        end
    until inv_delay == nil
end

function lss_thread()
    lss_delay = 'get'
    repeat wait(0)
        if lss_delay == 'get' then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            lss_delay = 'get1'
            sampSendChat('/mat get')
        end
        if lss_delay == 'put' then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            lss_delay = 'put1'
            sampSendChat('/mat put')
        end
    until lss_delay == nil
    lss = false
end

-- HOOK

function sampev.onSendChat(message) antiflood = os.clock() * 1000 end
function sampev.onSendCommand(cmd) antiflood = os.clock() * 1000
    if cmd:lower() == "/gh" then
        lua_thread.create(function()
            Dialog()
            start_dialog(dialog[1])
        end)
        return false
    end
    if cmd:lower():find("%/invite (%d+) (%d+)") then
        invID, invRank = cmd:lower():match("%/invite (%d+) (%d+)")
        return { '/invite '..invID }
    end
end

function sampev.onServerMessage(color, message)
    if message:find('Вы не на военном складе') or message:find('Склад военных пуст') or message:find('Необходимо находиться у фургона') or message:find('Фургон полный') then
        if lss_delay ~= nil then
            lss_delay = nil
            printStringNow('~G~Auto Loader: OFF', 2000)
        end
    end
    if message:find('У вас нет материалов с собой') or message:find('Вы уронили ящик') then
        if lss_delay == 'put1' then
            lss_delay = 'get'
        end
    end
    if message:find('У вас на руках уже есть материалы') then
        if lss_delay == 'get1' then
            lss_delay = 'put'
        end
    end
    if message:find('Вы взяли несколько комплектов, положите их в фургон') and lss_delay == 'get1' then lss_delay = 'put' end
    if message:find('Вы положили ящик в фургон. Материалов в фургоне (%d+)/(%d+)') and lss_delay == 'put1' then
        local S1, S2 = message:match('Вы положили ящик в фургон. Материалов в фургоне (%d+)/(%d+)')
        if S1 == S2 then
            lss_delay = nil
            printStringNow('~G~Auto Loader: OFF', 2000)
        else
            lss_delay = 'get'
        end
    end
    if string.find(message, " %(%( Остаток: (%d+) материалов %)%)") then
        ini[my_nick].matov = tonumber(string.match(message, " %(%( Остаток: (%d+) материалов %)%)"))
        inicfg.save(ini)
        makegun_delay = true
    end
    if message == ' У вас недостаточно материалов' or message:find('Необходимо находиться на своей территории')  then
        if sellgun ~= nil and #sellgun > 0 then
            makegun_delay = false
            sellgun = {}
        end
    end
    if string.find(message, " У вас (%d+)/(%d+) материалов с собой") then
        local S1, S2 = string.match(message, " У вас (%d+)/(%d+) материалов с собой")
        ini[my_nick].matov = tonumber(S1) ; ini[my_nick].max_matov = tonumber(S2)
        inicfg.save(ini)
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
        send_auto_getGuns_warehose = nil
    end
    if string.find(message, " (.*) забрал%(а%) у (.*) материалы") or (message:find('выбросил') and message:find('Материалы')) then
        local result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if string.find(message, sampGetPlayerNickname(id)) then ini[my_nick].matov = 0 inicfg.save(ini) end
    end
    if message == " Вы ограбили дом! Наворованный металл можно сдать около порта. (( /gps >> Прием металла ))" or message == " Провал. Сработала сигнализация" then
        ini[my_nick].matov = ini[my_nick].matov - 50
        inicfg.save(ini)
    end
    if message:find('Патронов должно быть от 1') then
        sellgun = {}
    end
    if message == ' Не флуди!' then
        if type(warehouse_delay) == 'string' and warehouse_delay:find('check') then
            warehouse_delay = warehouse_delay:gsub('check ', '')
        end
        if type(makegun_delay) == 'string' and makegun_delay:find('gun') then
            makegun_delay = false
        end
        if lss_delay ~= nil then
            lss_delay = lss_delay:gsub('1', '')
        end
        if inv_delay == 'giverank1' then
            inv_delay = 'giverank'
        end
        if warehouse_chekay == 2 then
            warehouse_chekay = 1
        end
    end
    if message == ' Вам недоступна эта функция' or message == " Ранг должен быть выше" then
        warehouse_delay = ''
        market_gun = false
    end
    if message == ' Необходимо находиться на своей базе' then
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
    end
    if message:find('На складе недостаточно материалов') then
        market_gun = false
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
    end
    if string.find(message, " (.*) закрыл%(а%) склад с оружием") then
        warehouse_status = false
        send_auto_getGuns_warehose = nil
        if warehouse_delay == 'check warelock' then
            warehouse_delay = ''
        end
    end
    if string.find(message, " (.*) открыл%(а%) склад с оружием") then
        warehouse_status = true
        if warehouse_delay == 'check warelock' then
            warehouse_delay = 'get guns'
        end
        if warehouse_check then
            lua_thread.create(function()
                for k,v in pairs(coord_resp) do
                    local dist = math.floor(getDistanceBetweenCoords3d(v[1], v[2], v[3], getCharCoordinates(playerPed)))
                    if dist <= 100.0 then
                        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
                        sampSendChat('/get guns')
                        break
                    end
                end
            end)
        end
    end
    if string.find(message, " Склад ") and (string.find(message, "00AB06") or string.find(message, "C42100")) then
        if string.find(message, "00AB06") then
            warehouse_status = true
            if warehouse_delay == 'check warehouse' then
                warehouse_delay = 'get guns'
            end
        end
        if string.find(message, "C42100") then
            warehouse_status = false
            if warehouse_delay == 'check warehouse' then
                warehouse_delay = 'warelock'
            end
        end
        warehouse_check = false
        if warehouse_chekay == 2 then
            return false
        end
    end
    if message:find(' (%d+)/(%d+) Матов | (%d+)/(%d+) Аптечек') then
        local s1, s2, s3, s4 = message:match(' (%d+)/(%d+) Матов | (%d+)/(%d+) Аптечек')
        if warehouse_chekay == 2 then
            warehouse_chekay = nil
            printStringNow((ini[my_nick].matov > 0 and '~W~Mats: ' or '~R~Mats: ')..ini[my_nick].matov..'/'..ini[my_nick].max_matov..'~N~~W~Warehouse '..s1..'/'..s2, 7000)
            return false
        end
    end
    if message:find(' Вы приняли .+ в') and invID ~= nil and invRank ~= nil then
        if invRank ~= nil then
            lua_thread.create(function()
                inv_delay = 'giverank'
                repeat wait(0)
                    if inv_delay == 'giverank' then
                        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
                        local lvl = sampGetPlayerScore(invID)
                        if lvl < ini[my_nick].lvl_rank and invRank >= 7 then
                            invRank = 6
                        end
                        inv_delay = 'giverank1'
                        sampSendChat('/giverank '..invID..' '..invRank)
                    end
                until invRank == nil
            end)
        end
    end
    if message:find(' Вы повысили/понизили .+ до %d+ ранга') or message == ' Ошибка. Ранг игрока выше или равен вашему' or message:find('Вам недоступна эта функция!') then
        invRank = nil
        invID = nil
    end
    if message == ' Необходимо находиться рядом друг с другом!' then
        invRank = nil
        invID = nil
    end
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if string.find(title, "Карманы") and style == 4 then
        local array = split(text, '\n')
        for k, string in pairs(array) do
            if string.find(string, "Материалы") then
                ini[my_nick].matov = tonumber(string.match(string, "Материалы.(%d+) / %d+"))
                ini[my_nick].max_matov = tonumber(string.match(string, "Материалы.%d+ / (%d+)"))
                inicfg.save(ini)
            end
        end
        if not string.find(text, "Материалы") then ini[my_nick].matov = 0 inicfg.save(ini) end
        if inv_delay ~= nil and inv_delay == 'send' then
            inv_delay = nil
            warehouse_chekay = true
            lua_thread.create(function()
                warehouse_chekay = 1
                repeat wait(0)
                    if (os.clock() * 1000 - antiflood) > 1100 then
                        if warehouse_chekay == 1 then
                            warehouse_chekay = 2
                            sampSendChat('/warehouse')
                        end
                    end
                until warehouse_chekay == nil
            end)
            return false
        end
    end
end

function sampev.onSendDialogResponse(dialogId, button, listboxId, input)

end


-- Dialog
function Dialog()
dialog = {
    {
        settings = {title = "GANG-HELPER" ,style = 4 ,btn1 = "Далее" ,btn2 = "Закрыть" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            {
                title = "Взятие материалов со склада\t Key: "..ini.Settings.get_guns:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('get_guns')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Проверить материалы\t Key: "..ini.Settings.inventory:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('inventory')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Открыть склад, взять маты, закрыть\t Key: "..ini.Settings.warelock_get_guns_warelock:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('warelock_get_guns_warelock')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Разгрузить фуру\t Key: "..ini.Settings.unloading:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('unloading')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Загрузка ящиков\t Key: "..ini.Settings.mat_get_put:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('mat_get_put')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Сделать оружие из лички\t Key: "..ini.Settings.gun:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('gun')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = " \t ",
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[(button == 0 and 1 or 2)]
                    end
                end
            },
            {
                title = "Минимальный LVL для 7 ранга\t"..ini[my_nick].lvl_rank..' LVL',
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[4]
                    end
                end
            },
            {
                title = "Список оружия которое нужно делать\t",
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[2]
                    end
                end
            },
            {
                title = "Описание скрипта\t",
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[6]
                    end
                end
            },
        },
    },
    {
        settings = {title = "GUN MARKET" ,style = 4 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = true},
        {
            {
                title = "Materials\t"..materials()..'/'..ini[my_nick].max_matov,
                click = function(button, list, input , outs)
                    return dialog[(button == 0 and 1 or 2)]
                end
            },
            {
                title = "Silend Pistol\t"..ini.gun.silend_pistol..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Deagle\t"..ini.gun.deagle..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Shotgun\t"..ini.gun.shotgun..' pt.',
                click = function(button, list, input , outs)
                   return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "SMG\t"..ini.gun.smg..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "M4\t"..ini.gun.m4..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "AK-47\t"..ini.gun.ak47..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Rifle\t"..ini.gun.rifle..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Описание функции.\t",
                click = function(button, list, input , outs)
                    return (button == 1 and dialog[5] or dialog[1])
                end
            },
        }
    },
    {
       settings = {title = "GUN PT" ,style = 1 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = "Введите количество патрон.\nВпишите 0 если вам не нужно это оружие.",
            {
                click = function(button, list, input , outs)
                    if button == 0 then
                        return dialog[2]
                    else
                        if input:find('%d+') then
                            local S1 = ini.gun[market_gun_name]
                            ini.gun[market_gun_name] = tonumber(input:match('(%d+)'))
                            if not materials(1) then
                                ini.gun[market_gun_name] = S1
                                local mat = math.ceil((ini[my_nick].max_matov - materials()) / gunlist[market_gun_name])
                                if mat <= 0 then mat = 0 end
                                sampAddChatMessage("Ошибка. Вы привысили лимит материалов. Доступно: "..mat..' патрон.' , 0xffcecece)
                            end
                            inicfg.save(ini)
                            Dialog()
                            return dialog[2]
                        else
                            sampAddChatMessage("Ошибка. Введите кол-во патрон.", 0xffcecece)
                            return dialog[3]
                        end
                    end
                end
            }
        }
    },
    {
       settings = {title = "RANK INVITE" ,style = 1 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = "В скрипте есть функция повышения игрока сразу после принятия > /invite [ID] [Rank]\nДля того чтобы не проверять LVL игрока - укажите минимальный LVL для 7 ранга.\nЕсли выдаваемый ранг будет выше 6, а уровень будет не соответствовать, тогда игроку будет выдан 6 ранг.",
            {
                click = function(button, list, input , outs)
                    if button == 0 then
                        return dialog[1]
                    else
                        if input:find('%d+') then
                            local lvl = tonumber(input:match('(%d+)'))
                            if lvl > 0 then
                                ini[my_nick].lvl_rank = lvl
                            else
                                sampAddChatMessage("Ошибка. Введите число от 1.", 0xffcecece)
                                return dialog[4]
                            end
                            inicfg.save(ini)
                            Dialog()
                            return dialog[1]
                        else
                            sampAddChatMessage("Ошибка. Введите число от 1.", 0xffcecece)
                            return dialog[4]
                        end
                    end
                end
            }
        }
    },
    {
       settings = {title = "README MARKET" ,style = 0 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = "Функция для использования лички.\nПо нажатию клавиши делает оружие которое вы указали при настройке.\nМожно сделать столько патрон - на сколько хватает лички.\n\nВ первой строке написано на сколько использован лимит.\nПри превышении лимита вам напишет допустимое кол-во патрон.",
            {
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[5]
                    else
                        return dialog[2]
                    end
                end
            }
        }
    },
    {
       settings = {title = "Страница 1" ,style = 0 ,btn1 = "Страница 2" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = '1. Взятие материалов со склада\n- Первый вариант вы просто нажимаете кнопку - он берет маты со склада.\n- Второй вариант вы зажимаете кнопку на секунду - включается взятие матов сразу после открытия склада.\nБудет работать пока не релогнитесь или не отключите таким же способом.\n\n2. Проверить материалы и склад\nПросто проверяет inventory/warehouse и показывает на экране.\n\n3. Открыть склад, взять маты, закрыть\nЕсли скрипту не известен статус склада - он проверяет по /warehouse.\nЕсли склад закрыт - открывает его и берет маты, после закрывает.\nЕсли склад открыт - берет маты и закрывает склад.\n\n4. Разгрузить фуру\nПросто бинд на /unloading',
            {
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[7]
                    else
                        return dialog[1]
                    end
                end
            }
        }
    },
    {
       settings = {title = "README" ,style = 0 ,btn1 = "Понятно" ,btn2 = "Страница 1" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = '5. Сделать оружие из лички\nНиже в меню есть Список оружия которое нужно делать, там указываете кол-во патрон под нужный вам тип оружия.\nНельзя превышать максимальное значение вашей лички.\nЕсли лички не хватает, он сделает столько патрон - на сколько хватит материалов.\n\n6. Повышение после инвайта\nДоработана команда инвайта, после принятия игрока скрипт может его повысить.\nТолько если после ID  вы укажите ранг на который нужно повысить.\nПример: /invite [ID] [Rank]\nТак же в настройках есть мин. лвл для 7 ранга.\nЕсли вы принимаете игрока на 7+ ранг, а у него ЛВЛ меньше требуемого - выдаст 6 ранг.',
            {
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[7]
                    else
                        return dialog[6]
                    end
                end
            }
        }
    },
}
end

function MarketFunc(button, list, input , outs)
    if button == 0 then
        return dialog[2]
    else
        local key = { 'silend_pistol', 'deagle', 'shotgun', 'smg', 'm4', 'ak47', 'rifle' }
        for i = 1, 7 do
            if i == list then
                if key[list] ~= nil then
                    market_gun_name = key[list]
                    return 3
                else
                    sampAddChatMessage("Ошибка. Что то пошло не так.", 0xffcecece)
                    return 0
                end
            end
        end
    end
end

function materials(is)
    local mats = 0
    for k,v in pairs(ini.gun) do
        if v > 0 then
            mats = mats + (v * gunlist[k])
        end
    end
    if is ~= nil then
        if ini[my_nick].max_matov < mats then
            return false
        else
            return true
        end
    else
        return mats
    end
end

function SetKey(keys)
    wait(300)
    sampAddChatMessage('Нажмите на нужную Вам клавишу! Чтобы отключить вообще: нажмите Enter', -1)
    local key = ""
    repeat
        wait(0)
        for k, v in pairs(vkeys) do
            if wasKeyPressed(v) and k ~= "VK_ESCAPE" then
                key = k
            end
        end
    until key ~= ""
    ini.Settings[keys] = key
    inicfg.save(ini)
    wait(300)
end

function ON_OFF(bool)
    return (bool and '{45d900}ON' or '{ff0000}OFF')
end

-- Function Dialog
function start_dialog(menu)
    function _dialog(menu, id,  outs)
        sampShowDialog(id, menu.settings.title, tbl_split(menu.settings.style, menu, menu.settings.forward ,menu.settings.backwards ,menu.settings.score), menu.settings.btn1, (menu.settings.btn2 ~= nil and menu.settings.btn2 or _), menu.settings.style)
            repeat
                wait(0)
                local result, button, list, input = sampHasDialogRespond(id)
                if result then
                    local out, outs = menu[((menu.settings.style == 0 or menu.settings.style == 1 or menu.settings.style == 3) and 1 or ((list + 1) > #menu[1] and 2 or 1))][((menu.settings.style == 0 or menu.settings.style == 1 or menu.settings.style == 3) and 1 or ((list + 1) > #menu[1] and (list - #menu[1]) + 1  or list + 1))].click(button, list, input, outs)
                    if type(out) == "table" then
                        return _dialog(out, id - 1, outs)
                    elseif type(out) == "boolean" then
                        if not out then
                            return out
                        end
                            return _dialog(menu, id, outs)
                    end
                end
            until result
    end

    function tbl_split(style, tbl, forward ,backwards ,score)
        if style == 2 or style == 4 or style == 5 then
            text = (style == 5 and tbl[1].text.."\n" or "")
            for i, val in ipairs(tbl[1]) do
                text = text..""..forward..""..(score and "["..i.."]{ffffff} " or "")..""..val.title..""..backwards
            end
            if tbl[2] ~= nil then
                for _, val in ipairs(tbl[2]) do
                    text = text..""..forward..""..val.title..""..backwards
                end
            end
            return text
        end
        return tbl[1].text
    end

    return _dialog(menu, 1337, outs)
end


--- Function split
function split(str, delim, plain)
    local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]]
    repeat
        local npos, epos = string.find(str, delim, pos, plain)
        table.insert(tokens, string.sub(str, pos, npos and npos - 1))
        pos = epos and epos + 1
    until not pos
    return tokens
end

function split(str, delim, plain)
    local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]]
    repeat
        local npos, epos = string.find(str, delim, pos, plain)
        table.insert(tokens, string.sub(str, pos, npos and npos - 1))
        pos = epos and epos + 1
    until not pos
    return tokens
end
я бы лучше переписал код, под +- оптимальную норму
сейчас посмотрим что можно сделать

Ошибка:
attempt to index global 'ini' (a nil value)
stack traceback:
код:
Код:
script_name('GANG-HELPER')
script_author("Serhiy_Rubin")

local inicfg, sampev, vkeys = require 'inicfg', require 'lib.samp.events', require 'lib.vkeys'
require 'lib.sampfuncs'
require 'lib.moonloader'
local antiflood = os.clock() * 1000 ; timer = os.clock() ; adid = 21 ; warehouse_status = nil ; warehouse_check = false ; warehouse_delay = 0 ; lss = false
local gunlist = { ['silend_pistol'] = 1, ['deagle'] = 3, ['shotgun'] = 3, ['smg'] = 2, ['m4'] = 3, ['ak47'] = 3, ['rifle'] = 5 }
local coord_resp = {
    {2494.29296875, -1681.8502197266, 12.338387489319}, -- grove
    {2183.3081054688, -1807.8851318359, 12.373405456543}, -- rifa
    {287.72546386719, -141.66345214844, 1006.15625}, -- rifa inta
    {1582.6881103516, -1597.0266113281, 27.475524902344}, -- aztec inta
    {1672.9483642578, -2113.423828125, 12.546875}, -- aztec
    {2647.3308105469, -2029.4759521484, 12.546875}, -- ballas
    {607.73522949219, -147.71377563477, 0}, -- ballas inta
    {2780.3444824219, -1615.7406005859, 9.921875}, -- vagos
    {358.85055541992, 34.617668151855, 0} -- vagos inta
}
local skin = { 41, 114, 115, 116, 56, 105, 106, 107, 269, 270, 271, 195, 102, 103, 104, 190, 108, 109, 110, 226, 173, 174, 175 }

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    repeat wait(0) until sampGetCurrentServerName() ~= 'SA-MP'
    repeat
        wait(0)
        local result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if result then
            score = sampGetPlayerScore(id)
        end
        for i = 1, #skin do
            if isCharModel(PLAYER_PED, skin[i]) then z = 1 end
        end
    until score >= 1 and z ~= nil
    _, my_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    my_nick = sampGetPlayerNickname(my_id)
    ini = inicfg.load({
        Settings = {
            get_guns = 'VK_1',
            warelock_get_guns_warelock = 'VK_3',
            unloading = 'VK_U',
            mat_get_put = 'VK_P',
            gun = 'VK_4',
            inventory = 'VK_M'
        },
        gun = {
            silend_pistol = 0,
            deagle = 0,
            shotgun = 0,
            smg = 0,
            m4 = 0,
            ak47 = 0,
            rifle = 0
        },
        [my_nick] = {
            matov = 0,
            max_matov = 500,
            warelock = false,
            lvl_rank = 6
        }
    })
    inicfg.save(ini)
    while true do
        wait(0)
        doKeyCheck()
    end
end

-- main
function doKeyCheck()
    type(makegun_delay)
    if (not sampIsDialogActive() or (sampGetCurrentDialogType() ~= 1 and sampGetCurrentDialogType() ~= 3)) and not sampIsChatInputActive() then
        if ini.Settings.get_guns ~= "VK_RETURN" and wasKeyPressed(vkeys[ini.Settings.get_guns]) then
            press_time = os.clock() * 1000
        end
        if press_time ~= nil then
            local sc = (os.clock() * 1000 - press_time)
            if isKeyDown(vkeys[ini.Settings.get_guns]) then
                if sc > 800 then
                    warehouse_check = not warehouse_check
                    printStringNow((warehouse_check and '~G~Auto GetGuns: ON' or '~G~Auto GetGuns: OFF'), 1000)
                    press_time = nil
                end
            else
                if sc < 500 then
                    repeat wait(0) until (os.clock() * 1000 - antiflood) > 1000
                    sampSendChat('/get guns')
                    press_time = nil
                end
            end
        end
        if ini.Settings.unloading ~= "VK_RETURN" and wasKeyPressed(vkeys[ini.Settings.unloading]) then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1000
            sampSendChat('/unloading')
        end
        if ini.Settings.warelock_get_guns_warelock ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.warelock_get_guns_warelock]) then
            lua_thread.create(unlock_getguns_lock)
        end
        if ini.Settings.gun ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.gun]) then
            lua_thread.create(makegun)
        end
        if ini.Settings.inventory ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.inventory]) then
            lua_thread.create(inv_check)
        end
        if ini.Settings.mat_get_put ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.mat_get_put]) then
            lss = not lss
            if lss then lua_thread.create(lss_thread) end
            printStringNow((lss and '~G~Auto Loader: ON' or '~G~Auto Loader: OFF'), 1000)
        end
    end
end

function unlock_getguns_lock()
    warehouse_delay = 'warehouse'
    repeat
        wait(0)
        if (os.clock() * 1000 - antiflood) > 1100 then
            if warehouse_delay == 'warehouse' then
                if warehouse_status == nil then
                    warehouse_delay    = 'check warehouse'
                    sampSendChat('/warehouse')
                elseif warehouse_status then
                    warehouse_delay = 'get guns'
                elseif not warehouse_status then
                    warehouse_delay = 'check warelock'
                    sampSendChat('/warelock')
                end
            end
            if warehouse_delay == 'get guns' then
                warehouse_delay = 'check get guns'
                sampSendChat('/get guns')
            end
            if warehouse_delay == 'warelock' then
                warehouse_delay = 'check warelock'
                sampSendChat('/warelock')
            end
        end
    until warehouse_delay == ''
end

function makegun()
    makegun_delay = ''
    local key = { 'silend_pistol', 'deagle', 'shotgun', 'smg', 'm4', 'ak47', 'rifle' }
    local arr = {}
    sellgun = {}
    for k, v in pairs(ini.gun) do
        if v > 0 then
            arr[#arr + 1] = { gun = k, pt = v }
        end
    end
    for i = #arr, 1, -1 do
        sellgun[#sellgun + 1] = { gun = arr[i].gun, pt = arr[i].pt }
    end
    repeat
        wait(0)
        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
        if #sellgun > 0 then
            local gun_name = sellgun[#sellgun].gun
            local pt = sellgun[#sellgun].pt
            local can = ini[my_nick].matov / gunlist[gun_name]
            if pt <= can then
                makegun_delay = '/gun '..gun_name..' '..pt
                sampSendChat(makegun_delay)
                repeat wait(0) until type(makegun_delay) == 'boolean'
                if makegun_delay then sellgun[#sellgun].pt = sellgun[#sellgun].pt - pt end
                if sellgun[#sellgun].pt == nil or sellgun[#sellgun].pt == 0 then sellgun[#sellgun] = nil end
            else
                if can <= 0 then
                    sampAddChatMessage("Ошибка. Не хватает материалов.", 0xffcecece)
                    sellgun = {}
                else
                    makegun_delay = '/gun '..gun_name..' '..can - 1
                    sampSendChat(makegun_delay)
                    sellgun = {}
                end
            end
        end
    until #sellgun == 0
end

function inv_check()
    inv_delay = ''
    repeat wait(0)
        if inv_delay == '' then
            inv_delay = 'send'
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            sampSendChat('/inventory')
        end
    until inv_delay == nil
end

function lss_thread()
    lss_delay = 'get'
    repeat wait(0)
        if lss_delay == 'get' then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            lss_delay = 'get1'
            sampSendChat('/mat get')
        end
        if lss_delay == 'put' then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            lss_delay = 'put1'
            sampSendChat('/mat put')
        end
    until lss_delay == nil
    lss = false
end

-- HOOK

function sampev.onSendChat(message) antiflood = os.clock() * 1000 end
function sampev.onSendCommand(cmd) antiflood = os.clock() * 1000
    if cmd:lower() == "/gh" then
        lua_thread.create(function()
            Dialog()
            start_dialog(dialog[1])
        end)
        return false
    end
    if cmd:lower():find("%/invite (%d+) (%d+)") then
        invID, invRank = cmd:lower():match("%/invite (%d+) (%d+)")
        return { '/invite '..invID }
    end
end

function sampev.onServerMessage(color, message)
    if message:find('Вы не на военном складе') or message:find('Склад военных пуст') or message:find('Необходимо находиться у фургона') or message:find('Фургон полный') then
        if lss_delay ~= nil then
            lss_delay = nil
            printStringNow('~G~Auto Loader: OFF', 2000)
        end
    end
    if message:find('У вас нет материалов с собой') or message:find('Вы уронили ящик') then
        if lss_delay == 'put1' then
            lss_delay = 'get'
        end
    end
    if message:find('У вас на руках уже есть материалы') then
        if lss_delay == 'get1' then
            lss_delay = 'put'
        end
    end
    if message:find('Вы взяли несколько комплектов, положите их в фургон') and lss_delay == 'get1' then lss_delay = 'put' end
    if message:find('Вы положили ящик в фургон. Материалов в фургоне (%d+)/(%d+)') and lss_delay == 'put1' then
        local S1, S2 = message:match('Вы положили ящик в фургон. Материалов в фургоне (%d+)/(%d+)')
        if S1 == S2 then
            lss_delay = nil
            printStringNow('~G~Auto Loader: OFF', 2000)
        else
            lss_delay = 'get'
        end
    end
    if string.find(message, " %(%( Остаток: (%d+) материалов %)%)") then
        ini[my_nick].matov = tonumber(string.match(message, " %(%( Остаток: (%d+) материалов %)%)"))
        inicfg.save(ini)
        makegun_delay = true
    end
    if message == ' У вас недостаточно материалов' or message:find('Необходимо находиться на своей территории')  then
        if sellgun ~= nil and #sellgun > 0 then
            makegun_delay = false
            sellgun = {}
        end
    end
    if string.find(message, " У вас (%d+)/(%d+) материалов с собой") then
        local S1, S2 = string.match(message, " У вас (%d+)/(%d+) материалов с собой")
        ini[my_nick].matov = tonumber(S1) ; ini[my_nick].max_matov = tonumber(S2)
        inicfg.save(ini)
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
        send_auto_getGuns_warehose = nil
    end
    if string.find(message, " (.*) забрал%(а%) у (.*) материалы") or (message:find('выбросил') and message:find('Материалы')) then
        local result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if string.find(message, sampGetPlayerNickname(id)) then ini[my_nick].matov = 0 inicfg.save(ini) end
    end
    if message == " Вы ограбили дом! Наворованный металл можно сдать около порта. (( /gps >> Прием металла ))" or message == " Провал. Сработала сигнализация" then
        ini[my_nick].matov = ini[my_nick].matov - 50
        inicfg.save(ini)
    end
    if message:find('Патронов должно быть от 1') then
        sellgun = {}
    end
    if message == ' Не флуди!' then
        if type(warehouse_delay) == 'string' and warehouse_delay:find('check') then
            warehouse_delay = warehouse_delay:gsub('check ', '')
        end
        if type(makegun_delay) == 'string' and makegun_delay:find('gun') then
            makegun_delay = false
        end
        if lss_delay ~= nil then
            lss_delay = lss_delay:gsub('1', '')
        end
        if inv_delay == 'giverank1' then
            inv_delay = 'giverank'
        end
        if warehouse_chekay == 2 then
            warehouse_chekay = 1
        end
    end
    if message == ' Вам недоступна эта функция' or message == " Ранг должен быть выше" then
        warehouse_delay = ''
        market_gun = false
    end
    if message == ' Необходимо находиться на своей базе' then
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
    end
    if message:find('На складе недостаточно материалов') then
        market_gun = false
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
    end
    if string.find(message, " (.*) закрыл%(а%) склад с оружием") then
        warehouse_status = false
        send_auto_getGuns_warehose = nil
        if warehouse_delay == 'check warelock' then
            warehouse_delay = ''
        end
    end
    if string.find(message, " (.*) открыл%(а%) склад с оружием") then
        warehouse_status = true
        if warehouse_delay == 'check warelock' then
            warehouse_delay = 'get guns'
        end
        if warehouse_check then
            lua_thread.create(function()
                for k,v in pairs(coord_resp) do
                    local dist = math.floor(getDistanceBetweenCoords3d(v[1], v[2], v[3], getCharCoordinates(playerPed)))
                    if dist <= 100.0 then
                        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
                        sampSendChat('/get guns')
                        break
                    end
                end
            end)
        end
    end
    if string.find(message, " Склад ") and (string.find(message, "00AB06") or string.find(message, "C42100")) then
        if string.find(message, "00AB06") then
            warehouse_status = true
            if warehouse_delay == 'check warehouse' then
                warehouse_delay = 'get guns'
            end
        end
        if string.find(message, "C42100") then
            warehouse_status = false
            if warehouse_delay == 'check warehouse' then
                warehouse_delay = 'warelock'
            end
        end
        warehouse_check = false
        if warehouse_chekay == 2 then
            return false
        end
    end
    if message:find(' (%d+)/(%d+) Матов | (%d+)/(%d+) Аптечек') then
        local s1, s2, s3, s4 = message:match(' (%d+)/(%d+) Матов | (%d+)/(%d+) Аптечек')
        if warehouse_chekay == 2 then
            warehouse_chekay = nil
            printStringNow((ini[my_nick].matov > 0 and '~W~Mats: ' or '~R~Mats: ')..ini[my_nick].matov..'/'..ini[my_nick].max_matov..'~N~~W~Warehouse '..s1..'/'..s2, 7000)
            return false
        end
    end
    if message:find(' Вы приняли .+ в') and invID ~= nil and invRank ~= nil then
        if invRank ~= nil then
            lua_thread.create(function()
                inv_delay = 'giverank'
                repeat wait(0)
                    if inv_delay == 'giverank' then
                        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
                        local lvl = sampGetPlayerScore(invID)
                        if lvl < ini[my_nick].lvl_rank and invRank >= 7 then
                            invRank = 6
                        end
                        inv_delay = 'giverank1'
                        sampSendChat('/giverank '..invID..' '..invRank)
                    end
                until invRank == nil
            end)
        end
    end
    if message:find(' Вы повысили/понизили .+ до %d+ ранга') or message == ' Ошибка. Ранг игрока выше или равен вашему' or message:find('Вам недоступна эта функция!') then
        invRank = nil
        invID = nil
    end
    if message == ' Необходимо находиться рядом друг с другом!' then
        invRank = nil
        invID = nil
    end
end
ну вообщем у тебя,
1678102763465.png

все inicfg.(функция)(ini,'и отсутсвует название.ini'), у тебя можно сказать не идеть сохранение во всем скрипте
 

Lance_Sterling

Известный
799
277
сам ты

я барибал

я бы лучше переписал код, под +- оптимальную норму
сейчас посмотрим что можно сделать


ну вообщем у тебя, Посмотреть вложение 192380
все inicfg.(функция)(ini,'и отсутсвует название.ini'), у тебя можно сказать не идеть сохранение во всем скрипте
Чо можно и без этого будет название NameScript.lua.ini

Ноу нейм 😂

Ошибка:
attempt to index global 'ini' (a nil value)
stack traceback:
код:
Код:
script_name('GANG-HELPER')
script_author("Serhiy_Rubin")

local inicfg, sampev, vkeys = require 'inicfg', require 'lib.samp.events', require 'lib.vkeys'
require 'lib.sampfuncs'
require 'lib.moonloader'
local antiflood = os.clock() * 1000 ; timer = os.clock() ; adid = 21 ; warehouse_status = nil ; warehouse_check = false ; warehouse_delay = 0 ; lss = false
local gunlist = { ['silend_pistol'] = 1, ['deagle'] = 3, ['shotgun'] = 3, ['smg'] = 2, ['m4'] = 3, ['ak47'] = 3, ['rifle'] = 5 }
local coord_resp = {
    {2494.29296875, -1681.8502197266, 12.338387489319}, -- grove
    {2183.3081054688, -1807.8851318359, 12.373405456543}, -- rifa
    {287.72546386719, -141.66345214844, 1006.15625}, -- rifa inta
    {1582.6881103516, -1597.0266113281, 27.475524902344}, -- aztec inta
    {1672.9483642578, -2113.423828125, 12.546875}, -- aztec
    {2647.3308105469, -2029.4759521484, 12.546875}, -- ballas
    {607.73522949219, -147.71377563477, 0}, -- ballas inta
    {2780.3444824219, -1615.7406005859, 9.921875}, -- vagos
    {358.85055541992, 34.617668151855, 0} -- vagos inta
}
local skin = { 41, 114, 115, 116, 56, 105, 106, 107, 269, 270, 271, 195, 102, 103, 104, 190, 108, 109, 110, 226, 173, 174, 175 }

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    repeat wait(0) until sampGetCurrentServerName() ~= 'SA-MP'
    repeat
        wait(0)
        local result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if result then
            score = sampGetPlayerScore(id)
        end
        for i = 1, #skin do
            if isCharModel(PLAYER_PED, skin[i]) then z = 1 end
        end
    until score >= 1 and z ~= nil
    _, my_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    my_nick = sampGetPlayerNickname(my_id)
    ini = inicfg.load({
        Settings = {
            get_guns = 'VK_1',
            warelock_get_guns_warelock = 'VK_3',
            unloading = 'VK_U',
            mat_get_put = 'VK_P',
            gun = 'VK_4',
            inventory = 'VK_M'
        },
        gun = {
            silend_pistol = 0,
            deagle = 0,
            shotgun = 0,
            smg = 0,
            m4 = 0,
            ak47 = 0,
            rifle = 0
        },
        [my_nick] = {
            matov = 0,
            max_matov = 500,
            warelock = false,
            lvl_rank = 6
        }
    })
    inicfg.save(ini)
    while true do
        wait(0)
        doKeyCheck()
    end
end

-- main
function doKeyCheck()
    type(makegun_delay)
    if (not sampIsDialogActive() or (sampGetCurrentDialogType() ~= 1 and sampGetCurrentDialogType() ~= 3)) and not sampIsChatInputActive() then
        if ini.Settings.get_guns ~= "VK_RETURN" and wasKeyPressed(vkeys[ini.Settings.get_guns]) then
            press_time = os.clock() * 1000
        end
        if press_time ~= nil then
            local sc = (os.clock() * 1000 - press_time)
            if isKeyDown(vkeys[ini.Settings.get_guns]) then
                if sc > 800 then
                    warehouse_check = not warehouse_check
                    printStringNow((warehouse_check and '~G~Auto GetGuns: ON' or '~G~Auto GetGuns: OFF'), 1000)
                    press_time = nil
                end
            else
                if sc < 500 then
                    repeat wait(0) until (os.clock() * 1000 - antiflood) > 1000
                    sampSendChat('/get guns')
                    press_time = nil
                end
            end
        end
        if ini.Settings.unloading ~= "VK_RETURN" and wasKeyPressed(vkeys[ini.Settings.unloading]) then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1000
            sampSendChat('/unloading')
        end
        if ini.Settings.warelock_get_guns_warelock ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.warelock_get_guns_warelock]) then
            lua_thread.create(unlock_getguns_lock)
        end
        if ini.Settings.gun ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.gun]) then
            lua_thread.create(makegun)
        end
        if ini.Settings.inventory ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.inventory]) then
            lua_thread.create(inv_check)
        end
        if ini.Settings.mat_get_put ~= "VK_RETURN" and  wasKeyPressed(vkeys[ini.Settings.mat_get_put]) then
            lss = not lss
            if lss then lua_thread.create(lss_thread) end
            printStringNow((lss and '~G~Auto Loader: ON' or '~G~Auto Loader: OFF'), 1000)
        end
    end
end

function unlock_getguns_lock()
    warehouse_delay = 'warehouse'
    repeat
        wait(0)
        if (os.clock() * 1000 - antiflood) > 1100 then
            if warehouse_delay == 'warehouse' then
                if warehouse_status == nil then
                    warehouse_delay    = 'check warehouse'
                    sampSendChat('/warehouse')
                elseif warehouse_status then
                    warehouse_delay = 'get guns'
                elseif not warehouse_status then
                    warehouse_delay = 'check warelock'
                    sampSendChat('/warelock')
                end
            end
            if warehouse_delay == 'get guns' then
                warehouse_delay = 'check get guns'
                sampSendChat('/get guns')
            end
            if warehouse_delay == 'warelock' then
                warehouse_delay = 'check warelock'
                sampSendChat('/warelock')
            end
        end
    until warehouse_delay == ''
end

function makegun()
    makegun_delay = ''
    local key = { 'silend_pistol', 'deagle', 'shotgun', 'smg', 'm4', 'ak47', 'rifle' }
    local arr = {}
    sellgun = {}
    for k, v in pairs(ini.gun) do
        if v > 0 then
            arr[#arr + 1] = { gun = k, pt = v }
        end
    end
    for i = #arr, 1, -1 do
        sellgun[#sellgun + 1] = { gun = arr[i].gun, pt = arr[i].pt }
    end
    repeat
        wait(0)
        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
        if #sellgun > 0 then
            local gun_name = sellgun[#sellgun].gun
            local pt = sellgun[#sellgun].pt
            local can = ini[my_nick].matov / gunlist[gun_name]
            if pt <= can then
                makegun_delay = '/gun '..gun_name..' '..pt
                sampSendChat(makegun_delay)
                repeat wait(0) until type(makegun_delay) == 'boolean'
                if makegun_delay then sellgun[#sellgun].pt = sellgun[#sellgun].pt - pt end
                if sellgun[#sellgun].pt == nil or sellgun[#sellgun].pt == 0 then sellgun[#sellgun] = nil end
            else
                if can <= 0 then
                    sampAddChatMessage("Ошибка. Не хватает материалов.", 0xffcecece)
                    sellgun = {}
                else
                    makegun_delay = '/gun '..gun_name..' '..can - 1
                    sampSendChat(makegun_delay)
                    sellgun = {}
                end
            end
        end
    until #sellgun == 0
end

function inv_check()
    inv_delay = ''
    repeat wait(0)
        if inv_delay == '' then
            inv_delay = 'send'
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            sampSendChat('/inventory')
        end
    until inv_delay == nil
end

function lss_thread()
    lss_delay = 'get'
    repeat wait(0)
        if lss_delay == 'get' then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            lss_delay = 'get1'
            sampSendChat('/mat get')
        end
        if lss_delay == 'put' then
            repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
            lss_delay = 'put1'
            sampSendChat('/mat put')
        end
    until lss_delay == nil
    lss = false
end

-- HOOK

function sampev.onSendChat(message) antiflood = os.clock() * 1000 end
function sampev.onSendCommand(cmd) antiflood = os.clock() * 1000
    if cmd:lower() == "/gh" then
        lua_thread.create(function()
            Dialog()
            start_dialog(dialog[1])
        end)
        return false
    end
    if cmd:lower():find("%/invite (%d+) (%d+)") then
        invID, invRank = cmd:lower():match("%/invite (%d+) (%d+)")
        return { '/invite '..invID }
    end
end

function sampev.onServerMessage(color, message)
    if message:find('Вы не на военном складе') or message:find('Склад военных пуст') or message:find('Необходимо находиться у фургона') or message:find('Фургон полный') then
        if lss_delay ~= nil then
            lss_delay = nil
            printStringNow('~G~Auto Loader: OFF', 2000)
        end
    end
    if message:find('У вас нет материалов с собой') or message:find('Вы уронили ящик') then
        if lss_delay == 'put1' then
            lss_delay = 'get'
        end
    end
    if message:find('У вас на руках уже есть материалы') then
        if lss_delay == 'get1' then
            lss_delay = 'put'
        end
    end
    if message:find('Вы взяли несколько комплектов, положите их в фургон') and lss_delay == 'get1' then lss_delay = 'put' end
    if message:find('Вы положили ящик в фургон. Материалов в фургоне (%d+)/(%d+)') and lss_delay == 'put1' then
        local S1, S2 = message:match('Вы положили ящик в фургон. Материалов в фургоне (%d+)/(%d+)')
        if S1 == S2 then
            lss_delay = nil
            printStringNow('~G~Auto Loader: OFF', 2000)
        else
            lss_delay = 'get'
        end
    end
    if string.find(message, " %(%( Остаток: (%d+) материалов %)%)") then
        ini[my_nick].matov = tonumber(string.match(message, " %(%( Остаток: (%d+) материалов %)%)"))
        inicfg.save(ini)
        makegun_delay = true
    end
    if message == ' У вас недостаточно материалов' or message:find('Необходимо находиться на своей территории')  then
        if sellgun ~= nil and #sellgun > 0 then
            makegun_delay = false
            sellgun = {}
        end
    end
    if string.find(message, " У вас (%d+)/(%d+) материалов с собой") then
        local S1, S2 = string.match(message, " У вас (%d+)/(%d+) материалов с собой")
        ini[my_nick].matov = tonumber(S1) ; ini[my_nick].max_matov = tonumber(S2)
        inicfg.save(ini)
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
        send_auto_getGuns_warehose = nil
    end
    if string.find(message, " (.*) забрал%(а%) у (.*) материалы") or (message:find('выбросил') and message:find('Материалы')) then
        local result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if string.find(message, sampGetPlayerNickname(id)) then ini[my_nick].matov = 0 inicfg.save(ini) end
    end
    if message == " Вы ограбили дом! Наворованный металл можно сдать около порта. (( /gps >> Прием металла ))" or message == " Провал. Сработала сигнализация" then
        ini[my_nick].matov = ini[my_nick].matov - 50
        inicfg.save(ini)
    end
    if message:find('Патронов должно быть от 1') then
        sellgun = {}
    end
    if message == ' Не флуди!' then
        if type(warehouse_delay) == 'string' and warehouse_delay:find('check') then
            warehouse_delay = warehouse_delay:gsub('check ', '')
        end
        if type(makegun_delay) == 'string' and makegun_delay:find('gun') then
            makegun_delay = false
        end
        if lss_delay ~= nil then
            lss_delay = lss_delay:gsub('1', '')
        end
        if inv_delay == 'giverank1' then
            inv_delay = 'giverank'
        end
        if warehouse_chekay == 2 then
            warehouse_chekay = 1
        end
    end
    if message == ' Вам недоступна эта функция' or message == " Ранг должен быть выше" then
        warehouse_delay = ''
        market_gun = false
    end
    if message == ' Необходимо находиться на своей базе' then
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
    end
    if message:find('На складе недостаточно материалов') then
        market_gun = false
        if warehouse_delay == 'check get guns' then warehouse_delay = 'warelock' end
    end
    if string.find(message, " (.*) закрыл%(а%) склад с оружием") then
        warehouse_status = false
        send_auto_getGuns_warehose = nil
        if warehouse_delay == 'check warelock' then
            warehouse_delay = ''
        end
    end
    if string.find(message, " (.*) открыл%(а%) склад с оружием") then
        warehouse_status = true
        if warehouse_delay == 'check warelock' then
            warehouse_delay = 'get guns'
        end
        if warehouse_check then
            lua_thread.create(function()
                for k,v in pairs(coord_resp) do
                    local dist = math.floor(getDistanceBetweenCoords3d(v[1], v[2], v[3], getCharCoordinates(playerPed)))
                    if dist <= 100.0 then
                        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
                        sampSendChat('/get guns')
                        break
                    end
                end
            end)
        end
    end
    if string.find(message, " Склад ") and (string.find(message, "00AB06") or string.find(message, "C42100")) then
        if string.find(message, "00AB06") then
            warehouse_status = true
            if warehouse_delay == 'check warehouse' then
                warehouse_delay = 'get guns'
            end
        end
        if string.find(message, "C42100") then
            warehouse_status = false
            if warehouse_delay == 'check warehouse' then
                warehouse_delay = 'warelock'
            end
        end
        warehouse_check = false
        if warehouse_chekay == 2 then
            return false
        end
    end
    if message:find(' (%d+)/(%d+) Матов | (%d+)/(%d+) Аптечек') then
        local s1, s2, s3, s4 = message:match(' (%d+)/(%d+) Матов | (%d+)/(%d+) Аптечек')
        if warehouse_chekay == 2 then
            warehouse_chekay = nil
            printStringNow((ini[my_nick].matov > 0 and '~W~Mats: ' or '~R~Mats: ')..ini[my_nick].matov..'/'..ini[my_nick].max_matov..'~N~~W~Warehouse '..s1..'/'..s2, 7000)
            return false
        end
    end
    if message:find(' Вы приняли .+ в') and invID ~= nil and invRank ~= nil then
        if invRank ~= nil then
            lua_thread.create(function()
                inv_delay = 'giverank'
                repeat wait(0)
                    if inv_delay == 'giverank' then
                        repeat wait(0) until (os.clock() * 1000 - antiflood) > 1100
                        local lvl = sampGetPlayerScore(invID)
                        if lvl < ini[my_nick].lvl_rank and invRank >= 7 then
                            invRank = 6
                        end
                        inv_delay = 'giverank1'
                        sampSendChat('/giverank '..invID..' '..invRank)
                    end
                until invRank == nil
            end)
        end
    end
    if message:find(' Вы повысили/понизили .+ до %d+ ранга') or message == ' Ошибка. Ранг игрока выше или равен вашему' or message:find('Вам недоступна эта функция!') then
        invRank = nil
        invID = nil
    end
    if message == ' Необходимо находиться рядом друг с другом!' then
        invRank = nil
        invID = nil
    end
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if string.find(title, "Карманы") and style == 4 then
        local array = split(text, '\n')
        for k, string in pairs(array) do
            if string.find(string, "Материалы") then
                ini[my_nick].matov = tonumber(string.match(string, "Материалы.(%d+) / %d+"))
                ini[my_nick].max_matov = tonumber(string.match(string, "Материалы.%d+ / (%d+)"))
                inicfg.save(ini)
            end
        end
        if not string.find(text, "Материалы") then ini[my_nick].matov = 0 inicfg.save(ini) end
        if inv_delay ~= nil and inv_delay == 'send' then
            inv_delay = nil
            warehouse_chekay = true
            lua_thread.create(function()
                warehouse_chekay = 1
                repeat wait(0)
                    if (os.clock() * 1000 - antiflood) > 1100 then
                        if warehouse_chekay == 1 then
                            warehouse_chekay = 2
                            sampSendChat('/warehouse')
                        end
                    end
                until warehouse_chekay == nil
            end)
            return false
        end
    end
end

function sampev.onSendDialogResponse(dialogId, button, listboxId, input)

end


-- Dialog
function Dialog()
dialog = {
    {
        settings = {title = "GANG-HELPER" ,style = 4 ,btn1 = "Далее" ,btn2 = "Закрыть" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            {
                title = "Взятие материалов со склада\t Key: "..ini.Settings.get_guns:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('get_guns')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Проверить материалы\t Key: "..ini.Settings.inventory:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('inventory')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Открыть склад, взять маты, закрыть\t Key: "..ini.Settings.warelock_get_guns_warelock:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('warelock_get_guns_warelock')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Разгрузить фуру\t Key: "..ini.Settings.unloading:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('unloading')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Загрузка ящиков\t Key: "..ini.Settings.mat_get_put:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('mat_get_put')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = "Сделать оружие из лички\t Key: "..ini.Settings.gun:gsub('VK_', ''):gsub('RETURN', 'OFF'),
                click = function(button, list, input , outs)
                    if button == 1 then
                        SetKey('gun')
                        Dialog()
                        return dialog[1]
                    end
                end
            },
            {
                title = " \t ",
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[(button == 0 and 1 or 2)]
                    end
                end
            },
            {
                title = "Минимальный LVL для 7 ранга\t"..ini[my_nick].lvl_rank..' LVL',
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[4]
                    end
                end
            },
            {
                title = "Список оружия которое нужно делать\t",
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[2]
                    end
                end
            },
            {
                title = "Описание скрипта\t",
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[6]
                    end
                end
            },
        },
    },
    {
        settings = {title = "GUN MARKET" ,style = 4 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = true},
        {
            {
                title = "Materials\t"..materials()..'/'..ini[my_nick].max_matov,
                click = function(button, list, input , outs)
                    return dialog[(button == 0 and 1 or 2)]
                end
            },
            {
                title = "Silend Pistol\t"..ini.gun.silend_pistol..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Deagle\t"..ini.gun.deagle..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Shotgun\t"..ini.gun.shotgun..' pt.',
                click = function(button, list, input , outs)
                   return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "SMG\t"..ini.gun.smg..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "M4\t"..ini.gun.m4..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "AK-47\t"..ini.gun.ak47..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Rifle\t"..ini.gun.rifle..' pt.',
                click = function(button, list, input , outs)
                    return dialog[MarketFunc(button, list, input , outs)]
                end
            },
            {
                title = "Описание функции.\t",
                click = function(button, list, input , outs)
                    return (button == 1 and dialog[5] or dialog[1])
                end
            },
        }
    },
    {
       settings = {title = "GUN PT" ,style = 1 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = "Введите количество патрон.\nВпишите 0 если вам не нужно это оружие.",
            {
                click = function(button, list, input , outs)
                    if button == 0 then
                        return dialog[2]
                    else
                        if input:find('%d+') then
                            local S1 = ini.gun[market_gun_name]
                            ini.gun[market_gun_name] = tonumber(input:match('(%d+)'))
                            if not materials(1) then
                                ini.gun[market_gun_name] = S1
                                local mat = math.ceil((ini[my_nick].max_matov - materials()) / gunlist[market_gun_name])
                                if mat <= 0 then mat = 0 end
                                sampAddChatMessage("Ошибка. Вы привысили лимит материалов. Доступно: "..mat..' патрон.' , 0xffcecece)
                            end
                            inicfg.save(ini)
                            Dialog()
                            return dialog[2]
                        else
                            sampAddChatMessage("Ошибка. Введите кол-во патрон.", 0xffcecece)
                            return dialog[3]
                        end
                    end
                end
            }
        }
    },
    {
       settings = {title = "RANK INVITE" ,style = 1 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = "В скрипте есть функция повышения игрока сразу после принятия > /invite [ID] [Rank]\nДля того чтобы не проверять LVL игрока - укажите минимальный LVL для 7 ранга.\nЕсли выдаваемый ранг будет выше 6, а уровень будет не соответствовать, тогда игроку будет выдан 6 ранг.",
            {
                click = function(button, list, input , outs)
                    if button == 0 then
                        return dialog[1]
                    else
                        if input:find('%d+') then
                            local lvl = tonumber(input:match('(%d+)'))
                            if lvl > 0 then
                                ini[my_nick].lvl_rank = lvl
                            else
                                sampAddChatMessage("Ошибка. Введите число от 1.", 0xffcecece)
                                return dialog[4]
                            end
                            inicfg.save(ini)
                            Dialog()
                            return dialog[1]
                        else
                            sampAddChatMessage("Ошибка. Введите число от 1.", 0xffcecece)
                            return dialog[4]
                        end
                    end
                end
            }
        }
    },
    {
       settings = {title = "README MARKET" ,style = 0 ,btn1 = "Далее" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = "Функция для использования лички.\nПо нажатию клавиши делает оружие которое вы указали при настройке.\nМожно сделать столько патрон - на сколько хватает лички.\n\nВ первой строке написано на сколько использован лимит.\nПри превышении лимита вам напишет допустимое кол-во патрон.",
            {
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[5]
                    else
                        return dialog[2]
                    end
                end
            }
        }
    },
    {
       settings = {title = "Страница 1" ,style = 0 ,btn1 = "Страница 2" ,btn2 = "Назад" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = '1. Взятие материалов со склада\n- Первый вариант вы просто нажимаете кнопку - он берет маты со склада.\n- Второй вариант вы зажимаете кнопку на секунду - включается взятие матов сразу после открытия склада.\nБудет работать пока не релогнитесь или не отключите таким же способом.\n\n2. Проверить материалы и склад\nПросто проверяет inventory/warehouse и показывает на экране.\n\n3. Открыть склад, взять маты, закрыть\nЕсли скрипту не известен статус склада - он проверяет по /warehouse.\nЕсли склад закрыт - открывает его и берет маты, после закрывает.\nЕсли склад открыт - берет маты и закрывает склад.\n\n4. Разгрузить фуру\nПросто бинд на /unloading',
            {
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[7]
                    else
                        return dialog[1]
                    end
                end
            }
        }
    },
    {
       settings = {title = "README" ,style = 0 ,btn1 = "Понятно" ,btn2 = "Страница 1" ,forward =  "{ffffff}" ,backwards = "\n" ,score = false},
        {
            text = '5. Сделать оружие из лички\nНиже в меню есть Список оружия которое нужно делать, там указываете кол-во патрон под нужный вам тип оружия.\nНельзя превышать максимальное значение вашей лички.\nЕсли лички не хватает, он сделает столько патрон - на сколько хватит материалов.\n\n6. Повышение после инвайта\nДоработана команда инвайта, после принятия игрока скрипт может его повысить.\nТолько если после ID  вы укажите ранг на который нужно повысить.\nПример: /invite [ID] [Rank]\nТак же в настройках есть мин. лвл для 7 ранга.\nЕсли вы принимаете игрока на 7+ ранг, а у него ЛВЛ меньше требуемого - выдаст 6 ранг.',
            {
                click = function(button, list, input , outs)
                    if button == 1 then
                        return dialog[7]
                    else
                        return dialog[6]
                    end
                end
            }
        }
    },
}
end

function MarketFunc(button, list, input , outs)
    if button == 0 then
        return dialog[2]
    else
        local key = { 'silend_pistol', 'deagle', 'shotgun', 'smg', 'm4', 'ak47', 'rifle' }
        for i = 1, 7 do
            if i == list then
                if key[list] ~= nil then
                    market_gun_name = key[list]
                    return 3
                else
                    sampAddChatMessage("Ошибка. Что то пошло не так.", 0xffcecece)
                    return 0
                end
            end
        end
    end
end

function materials(is)
    local mats = 0
    for k,v in pairs(ini.gun) do
        if v > 0 then
            mats = mats + (v * gunlist[k])
        end
    end
    if is ~= nil then
        if ini[my_nick].max_matov < mats then
            return false
        else
            return true
        end
    else
        return mats
    end
end

function SetKey(keys)
    wait(300)
    sampAddChatMessage('Нажмите на нужную Вам клавишу! Чтобы отключить вообще: нажмите Enter', -1)
    local key = ""
    repeat
        wait(0)
        for k, v in pairs(vkeys) do
            if wasKeyPressed(v) and k ~= "VK_ESCAPE" then
                key = k
            end
        end
    until key ~= ""
    ini.Settings[keys] = key
    inicfg.save(ini)
    wait(300)
end

function ON_OFF(bool)
    return (bool and '{45d900}ON' or '{ff0000}OFF')
end

-- Function Dialog
function start_dialog(menu)
    function _dialog(menu, id,  outs)
        sampShowDialog(id, menu.settings.title, tbl_split(menu.settings.style, menu, menu.settings.forward ,menu.settings.backwards ,menu.settings.score), menu.settings.btn1, (menu.settings.btn2 ~= nil and menu.settings.btn2 or _), menu.settings.style)
            repeat
                wait(0)
                local result, button, list, input = sampHasDialogRespond(id)
                if result then
                    local out, outs = menu[((menu.settings.style == 0 or menu.settings.style == 1 or menu.settings.style == 3) and 1 or ((list + 1) > #menu[1] and 2 or 1))][((menu.settings.style == 0 or menu.settings.style == 1 or menu.settings.style == 3) and 1 or ((list + 1) > #menu[1] and (list - #menu[1]) + 1  or list + 1))].click(button, list, input, outs)
                    if type(out) == "table" then
                        return _dialog(out, id - 1, outs)
                    elseif type(out) == "boolean" then
                        if not out then
                            return out
                        end
                            return _dialog(menu, id, outs)
                    end
                end
            until result
    end

    function tbl_split(style, tbl, forward ,backwards ,score)
        if style == 2 or style == 4 or style == 5 then
            text = (style == 5 and tbl[1].text.."\n" or "")
            for i, val in ipairs(tbl[1]) do
                text = text..""..forward..""..(score and "["..i.."]{ffffff} " or "")..""..val.title..""..backwards
            end
            if tbl[2] ~= nil then
                for _, val in ipairs(tbl[2]) do
                    text = text..""..forward..""..val.title..""..backwards
                end
            end
            return text
        end
        return tbl[1].text
    end

    return _dialog(menu, 1337, outs)
end


--- Function split
function split(str, delim, plain)
    local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]]
    repeat
        local npos, epos = string.find(str, delim, pos, plain)
        table.insert(tokens, string.sub(str, pos, npos and npos - 1))
        pos = epos and epos + 1
    until not pos
    return tokens
end

function split(str, delim, plain)
    local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]]
    repeat
        local npos, epos = string.find(str, delim, pos, plain)
        table.insert(tokens, string.sub(str, pos, npos and npos - 1))
        pos = epos and epos + 1
    until not pos
    return tokens
end
А нет ини естб просто с мейна вытащи ини
 
  • Грустно
Реакции: qdIbp

qdIbp

Автор темы
Проверенный
1,383
1,139
Чо можно и без этого будет название NameScript.lua.ini
ну хз, я на постоянку пишу название, вот и вышло что по привычки
Чо можно и без этого будет название NameScript.lua.ini


Ноу нейм 😂
асам
Чо можно и без этого будет название NameScript.lua.ini


Ноу нейм 😂


А нет ини естб просто с мейна вытащи ини
ну вот, сам все решил, нечего пинговать народ
 

Lance_Sterling

Известный
799
277
ну хз, я на постоянку пишу название, вот и вышло что по привычки

асам

ну вот, сам все решил, нечего пинговать народ
Следующий раз надо будет нортона позвать
 
  • Нравится
Реакции: 4el0ve4ik и qdIbp