Вопросы по Lua скриптингу

Общая тема для вопросов по разработке скриптов на языке программирования Lua, в частности под MoonLoader.
  • Задавая вопрос, убедитесь, что его нет в списке частых вопросов и что на него ещё не отвечали (воспользуйтесь поиском).
  • Поищите ответ в теме посвященной разработке Lua скриптов в MoonLoader
  • Отвечая, убедитесь, что ваш ответ корректен.
  • Старайтесь как можно точнее выразить мысль, а если проблема связана с кодом, то обязательно прикрепите его к сообщению, используя блок [code=lua]здесь мог бы быть ваш код[/code].
  • Если вопрос связан с MoonLoader-ом первым делом желательно поискать решение на wiki.

Частые вопросы

Как научиться писать скрипты? С чего начать?
Информация - Гайд - Всё о Lua скриптинге для MoonLoader(https://blast.hk/threads/22707/)
Как вывести текст на русском? Вместо русского текста у меня какие-то каракули.
Изменить кодировку файла скрипта на Windows-1251. В Atom: комбинация клавиш Ctrl+Shift+U, в Notepad++: меню Кодировки -> Кодировки -> Кириллица -> Windows-1251.
Как получить транспорт, в котором сидит игрок?
Lua:
local veh = storeCarCharIsInNoSave(PLAYER_PED)
Как получить свой id или id другого игрока?
Lua:
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED) -- получить свой ид
local _, id = sampGetPlayerIdByCharHandle(ped) -- получить ид другого игрока. ped - это хендл персонажа
Как проверить, что строка содержит какой-то текст?
Lua:
if string.find(str, 'текст', 1, true) then
-- строка str содержит "текст"
end
Как эмулировать нажатие игровой клавиши?
Lua:
local game_keys = require 'game.keys' -- где-нибудь в начале скрипта вне функции main

setGameKeyState(game_keys.player.FIREWEAPON, -1) -- будет сэмулировано нажатие клавиши атаки
Все иды клавиш находятся в файле moonloader/lib/game/keys.lua.
Подробнее о функции setGameKeyState здесь: lua - setgamekeystate | BlastHack — DEV_WIKI(https://www.blast.hk/wiki/lua:setgamekeystate)
Как получить id другого игрока, в которого целюсь я?
Lua:
local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE) -- получить хендл персонажа, в которого целится игрок
if valid and doesCharExist(ped) then -- если цель есть и персонаж существует
  local result, id = sampGetPlayerIdByCharHandle(ped) -- получить samp-ид игрока по хендлу персонажа
  if result then -- проверить, прошло ли получение ида успешно
    -- здесь любые действия с полученным идом игрока
  end
end
Как зарегистрировать команду чата SAMP?
Lua:
-- До бесконечного цикла/задержки
sampRegisterChatCommand("mycommand", function (param)
     -- param будет содержать весь текст введенный после команды, чтобы разделить его на аргументы используйте string.match()
    sampAddChatMessage("MyCMD", -1)
end)
Крашит игру при вызове sampSendChat. Как это исправить?
Это происходит из-за бага в SAMPFUNCS, когда производится попытка отправки пакета определенными функциями изнутри события исходящих RPC и пакетов. Исправления для этого бага нет, но есть способ не провоцировать его. Вызов sampSendChat изнутри обработчика исходящих RPC/пакетов нужно обернуть в скриптовый поток с нулевой задержкой:
Lua:
function onSendRpc(id)
  -- крашит:
  -- sampSendChat('Send RPC: ' .. id)

  -- норм:
  lua_thread.create(function()
    wait(0)
    sampSendChat('Send RPC: ' .. id)
  end)
end
 
Последнее редактирование:

MrBidloKoder

Известный
425
248
Как изменить высоту чекпоинта (z не работает, не получается). Примерно так:
unknown-34.png


У меня получается только так:
unknown-41.png
 

Gruzin Gang

Всефорумный Грузин
824
610
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Нужна помощь c onCreateObject + sampAddChatMessage / отпишите в лс прошу https://vk.com/gru31n
 

S.Walston

Новичок
22
1
Такой вопрос, сделал что бы 2 луа работали одновремено, но когда ввожу /poisk то открывается другой луа

C++:
----------------------------------------------------------------------------------------

local limgui, imgui = pcall(require, 'imgui') assert(limgui, 'Library \'imgui\' not found.')
local limadd, imadd = pcall(require, 'imgui_addons') assert(limadd, 'Library \'imgui_addons\' not found.')
local lencoding, encoding = pcall(require, 'encoding') assert(lencoding, 'Library \'encoding\' not found.')

----------------------------------------------------------------------------------------

encoding.default = 'CP1251'
local u8 = encoding.UTF8
local sampev = require 'lib.samp.events'
local active = true
local mem = require 'memory'
local main_color = 0xFFFFFF
local tag = "{FFD700}[INFOBAR]:"
local keys = require 'vkeys'
local playsec = 0
local playmin = 0
local playhours = 0
local tables
local imgui = require 'imgui'
local encoding = require 'encoding'

----------------------------------------------------------------------------------------

activate = false

----------------------------------------------------------------------------------------

local window = imgui.ImBool(false)
local number_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

----------------------------------------------------------------------------------------

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    imgui.ShowCursor = false
    imgui.SetMouseCursor(-1)
    sampAddChatMessage("[Fantasy] Скрипт загружен. Специально для Fantasy Empire", 0xFFd86bf3)
    sampAddChatMessage("[Fantasy] Версия скрипта: v1.0", 0xFFd86bf3)
    sampRegisterChatCommand("poisk", function ()
        window.v = not window.v
    end)
    lua_thread.create(flooder)
    while true do
        wait(0)
        imgui.Process = window.v
    end
    wait(-1)
            playsec = playsec + 1
            if playsec == 60 and playmin then
                playmin = playmin + 1
                playsec = 0
            end
            if playmin == 60 then
                playhours = playhours + 1
                playmin = 0
            end
        if number_window_state.v == false then
        imgui.Process = true
        end
end

function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-0.1, 0)
    activeB = imgui.ImBool(activate)
    
    if window.v then
        
        imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth / 2, iScreenHeight / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(500, 350), imgui.Cond.FirstUseEver)
      
        imgui.Begin(u8"Fantasy Empire", window, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        
        imgui.Separator()
        
        if imgui.Button(u8 "Пиар семья 1 кликом!") then
            imgui.OpenPopup(u8 "Пиар семьи в радио и вип")
            lua_thread.create(function()
                sampSendChat("/vr Проходит набор в империю Fantasy. Все улучшения, Discord, Беседа в ВК. Звоните/Пишите", -1)
                wait(1000)
                sampSendChat("/ad 1 Проходит набор в империю Fantasy. Все улучшения, Discord, Беседа в ВК. Звоните/Пишите")
                wait(1000)
            end)
        end
        if imgui.Button(u8 "Выдать рацию") then
            imgui.OpenPopup(u8 "Выдать рацию новому")
            lua_thread.create(function()
                sampSendChat("/me резким движением рук снимает рюкзак с плеча, после чего открывает его", -1)
                wait(1000)
                sampSendChat("/me достает оттуда рацию, передает его человеку")
                wait(1000)
                sampSendChat("/todo Вот бери*улыбаясь", -1)
                wait(1000)
            end)
        end
        
        imgui.Separator()
        imgui.NewLine()
        
        imgui.Text(u8 'Авто - Пиар Fantasy Empire в вип чат')
        if imadd.ToggleButton(u8 "Sprunk##", activeB) then activate = not activate if activate then sampAddChatMessage('{FF69B4}Автопиар успешно включен!', -1) else sampAddChatMessage('{FF69B4}Вы выключили автопиар!', -1) end end
        imgui.SameLine(); imgui.Text(u8 'Нажми на кнопку, если хочешь включить пиар')
    end
    
    imgui.End()
end

function flooder()
    while true do
        if activate then
            sampSendChat("/vr Проходит набор в империю Fantasy. Все улучшения, Discord, Беседа в ВК. Звоните/Пишите")
        end
        wait(300000)
    end
end

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

    style.WindowPadding = imgui.ImVec2(8, 8)
    style.WindowRounding = 6
    style.ChildWindowRounding = 5
    style.FramePadding = imgui.ImVec2(5, 3)
    style.FrameRounding = 3.0
    style.ItemSpacing = imgui.ImVec2(5, 4)
    style.ItemInnerSpacing = imgui.ImVec2(4, 4)
    style.IndentSpacing = 21
    style.ScrollbarSize = 10.0
    style.ScrollbarRounding = 13
    style.GrabMinSize = 8
    style.GrabRounding = 1
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)

    colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 0.95)
    colors[clr.TextDisabled] = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.WindowBg] = ImVec4(0.13, 0.12, 0.12, 1.00)
    colors[clr.ChildWindowBg] = ImVec4(0.13, 0.12, 0.12, 1.00)
    colors[clr.PopupBg] = ImVec4(0.05, 0.05, 0.05, 0.94)
    colors[clr.Border] = ImVec4(0.53, 0.53, 0.53, 0.46)
    colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg] = ImVec4(0.00, 0.00, 0.00, 0.85)
    colors[clr.FrameBgHovered] = ImVec4(0.22, 0.22, 0.22, 0.40)
    colors[clr.FrameBgActive] = ImVec4(0.16, 0.16, 0.16, 0.53)
    colors[clr.TitleBg] = ImVec4(0.00, 0.00, 0.00, 1.00)
    colors[clr.TitleBgActive] = ImVec4(0.00, 0.00, 0.00, 1.00)
    colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.MenuBarBg] = ImVec4(0.12, 0.12, 0.12, 1.00)
    colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab] = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive] = ImVec4(0.48, 0.48, 0.48, 1.00)
    colors[clr.ComboBg] = ImVec4(0.24, 0.24, 0.24, 0.99)
    colors[clr.CheckMark] = ImVec4(0.79, 0.79, 0.79, 1.00)
    colors[clr.SliderGrab] = ImVec4(0.48, 0.47, 0.47, 0.91)
    colors[clr.SliderGrabActive] = ImVec4(0.56, 0.55, 0.55, 0.62)
    colors[clr.Button] = ImVec4(0.50, 0.50, 0.50, 0.63)
    colors[clr.ButtonHovered] = ImVec4(0.67, 0.67, 0.68, 0.63)
    colors[clr.ButtonActive] = ImVec4(0.26, 0.26, 0.26, 0.63)
    colors[clr.Header] = ImVec4(0.54, 0.54, 0.54, 0.58)
    colors[clr.HeaderHovered] = ImVec4(0.64, 0.65, 0.65, 0.80)
    colors[clr.HeaderActive] = ImVec4(0.25, 0.25, 0.25, 0.80)
    colors[clr.Separator] = ImVec4(0.58, 0.58, 0.58, 0.50)
    colors[clr.SeparatorHovered] = ImVec4(0.81, 0.81, 0.81, 0.64)
    colors[clr.SeparatorActive] = ImVec4(0.81, 0.81, 0.81, 0.64)
    colors[clr.ResizeGrip] = ImVec4(0.87, 0.87, 0.87, 0.53)
    colors[clr.ResizeGripHovered] = ImVec4(0.87, 0.87, 0.87, 0.74)
    colors[clr.ResizeGripActive] = ImVec4(0.87, 0.87, 0.87, 0.74)
    colors[clr.CloseButton] = ImVec4(0.45, 0.45, 0.45, 0.50)
    colors[clr.CloseButtonHovered] = ImVec4(0.70, 0.70, 0.90, 0.60)
    colors[clr.CloseButtonActive] = ImVec4(0.70, 0.70, 0.70, 1.00)
    colors[clr.PlotLines] = ImVec4(0.68, 0.68, 0.68, 1.00)
    colors[clr.PlotLinesHovered] = ImVec4(0.68, 0.68, 0.68, 1.00)
    colors[clr.PlotHistogram] = ImVec4(0.90, 0.77, 0.33, 1.00)
    colors[clr.PlotHistogramHovered] = ImVec4(0.87, 0.55, 0.08, 1.00)
    colors[clr.TextSelectedBg] = ImVec4(0.47, 0.60, 0.76, 0.47)
    colors[clr.ModalWindowDarkening] = ImVec4(0.88, 0.88, 0.88, 0.35)
end
black_grey()

function cmd_imgui(arg)
    number_window_state.v = not number_window_state.v
    imgui.Process = number_window_state.v or show_2_window.v
end

function imgui.OnDrawFrame()
    if not isCharInAnyCar(PLAYER_PED) then
        imgui.SetNextWindowPos(imgui.ImVec2(430, 824), imgui.Cond.FirstUseEver)
        imgui.ShowCursor = false
        imgui.SetMouseCursor(-1)
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        server = sampGetCurrentServerName(PLAYER_HANDLE)
        ip = sampGetCurrentServerAddress(PLAYER_PED)
        weap = getCurrentCharWeapon(PLAYER_PED)
        weaponid = getWeapontypeModel(weap)
        ammo = getAmmoInCharWeapon(PLAYER_PED, weap)
        nick = sampGetPlayerNickname(id)
        fFps = mem.getfloat(0xB7CB50, 4, false)   
        ping = sampGetPlayerPing(id)
        time = (os.date("%H",os.time())..':'..os.date("%M",os.time())..':'..os.date("%S",os.time()))
        date = (os.date("%d",os.time())..'/'..os.date("%m",os.time())..'/'..os.date("%Y",os.time()))
        Health = getCharHealth(PLAYER_PED)
        Armor = getCharArmour(PLAYER_PED)
        Level = sampGetPlayerScore(id)
        pspeed = getCharSpeed(PLAYER_PED)
        local online = getGameTimer()/100000
        local afk = os.clock() - online
        x,y,z = getCharCoordinates(PLAYER_PED)
        Hours = (os.date("%H", os.time()))
        Minuts = (os.date("%M", os.time()))
        Seconds = (os.date("%S", os.time()))
        imgui.Begin("INFOBAR | Coded by NNC.", window, imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoResize + imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.ShowBorders)
        imgui.Text("Server: " .. server, main_color)
        imgui.Text("NickName: " .. nick ..  " | ID: " .. id, main_color)
        imgui.Text("Online: " .. online .. " | AFK: " .. afk, main_color)
        imgui.End()
    else
        imgui.SetNextWindowPos(imgui.ImVec2(430, 824), imgui.Cond.FirstUseEver)
        imgui.ShowCursor = false
        imgui.SetMouseCursor(-1)
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        car = storeCarCharIsInNoSave(playerPed)
        carmodel = getCarModel(car)
        carname = getGxtText(getNameOfVehicleModel(carmodel))
        _, cid = sampGetVehicleIdByCarHandle(car)
        carhp = getCarHealth(car)
        cspeed = getCarSpeed(car)
        server = sampGetCurrentServerName(PLAYER_HANDLE)
        ip = sampGetCurrentServerAddress(PLAYER_PED)
        nick = sampGetPlayerNickname(id)
        fFps = mem.getfloat(0xB7CB50, 4, false)   
        ping = sampGetPlayerPing(id)
        time = (os.date("%H",os.time())..':'..os.date("%M",os.time())..':'..os.date("%S",os.time()))
        date = (os.date("%d",os.time())..'/'..os.date("%m",os.time())..'/'..os.date("%Y",os.time()))
        Health = getCharHealth(PLAYER_PED)
        Armor = getCharArmour(PLAYER_PED)
        Hours = (os.date("%H", os.time()))
        Minuts = (os.date("%M", os.time()))
        Seconds = (os.date("%S", os.time()))
        Level = sampGetPlayerScore(id)
        x,y,z = getCharCoordinates(PLAYER_PED)
        imgui.Begin("INFOBAR | Coded by NNC.", window, imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoResize + imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.ShowBorders)
        imgui.Text("Server: " .. server, main_color)
        imgui.Text("NickName: " .. nick ..  " | ID: " .. id, main_color)
        imgui.Text("Ping: " .. ping .. " | Level: " .. Level .. " | FPS: " .. math.floor(fFps), main_color)
        imgui.Text("Time: " .. time .. " | Date: " .. date, main_color)
        imgui.Text("City: " .. city[getCityPlayerIsIn(PLAYER_HANDLE)] .. " | PlayerTime: " .. playhours .. ":" .. playmin .. ":" .. playsec, main_color)
        imgui.Text("Health: " .. Health .. " | Armour: " .. Armor .. " | Speed: " .. math.floor(cspeed * 2.5), main_color)
        imgui.Text("CarHP: " .. carhp .. " | CarID: " .. cid .. " | CarType: " .. carmodel, main_color)
        imgui.Text("X: " .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z), main_color)
        imgui.End()   
    end
end
Не могли бы подсказать в чем проблема?
 

paulohardy

вы еще постите говно? тогда я иду к вам
Всефорумный модератор
1,892
1,255
Такой вопрос, сделал что бы 2 луа работали одновремено, но когда ввожу /poisk то открывается другой луа

C++:
----------------------------------------------------------------------------------------

local limgui, imgui = pcall(require, 'imgui') assert(limgui, 'Library \'imgui\' not found.')
local limadd, imadd = pcall(require, 'imgui_addons') assert(limadd, 'Library \'imgui_addons\' not found.')
local lencoding, encoding = pcall(require, 'encoding') assert(lencoding, 'Library \'encoding\' not found.')

----------------------------------------------------------------------------------------

encoding.default = 'CP1251'
local u8 = encoding.UTF8
local sampev = require 'lib.samp.events'
local active = true
local mem = require 'memory'
local main_color = 0xFFFFFF
local tag = "{FFD700}[INFOBAR]:"
local keys = require 'vkeys'
local playsec = 0
local playmin = 0
local playhours = 0
local tables
local imgui = require 'imgui'
local encoding = require 'encoding'

----------------------------------------------------------------------------------------

activate = false

----------------------------------------------------------------------------------------

local window = imgui.ImBool(false)
local number_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

----------------------------------------------------------------------------------------

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    imgui.ShowCursor = false
    imgui.SetMouseCursor(-1)
    sampAddChatMessage("[Fantasy] Скрипт загружен. Специально для Fantasy Empire", 0xFFd86bf3)
    sampAddChatMessage("[Fantasy] Версия скрипта: v1.0", 0xFFd86bf3)
    sampRegisterChatCommand("poisk", function ()
        window.v = not window.v
    end)
    lua_thread.create(flooder)
    while true do
        wait(0)
        imgui.Process = window.v
    end
    wait(-1)
            playsec = playsec + 1
            if playsec == 60 and playmin then
                playmin = playmin + 1
                playsec = 0
            end
            if playmin == 60 then
                playhours = playhours + 1
                playmin = 0
            end
        if number_window_state.v == false then
        imgui.Process = true
        end
end

function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-0.1, 0)
    activeB = imgui.ImBool(activate)
   
    if window.v then
       
        imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth / 2, iScreenHeight / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(500, 350), imgui.Cond.FirstUseEver)
     
        imgui.Begin(u8"Fantasy Empire", window, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
       
        imgui.Separator()
       
        if imgui.Button(u8 "Пиар семья 1 кликом!") then
            imgui.OpenPopup(u8 "Пиар семьи в радио и вип")
            lua_thread.create(function()
                sampSendChat("/vr Проходит набор в империю Fantasy. Все улучшения, Discord, Беседа в ВК. Звоните/Пишите", -1)
                wait(1000)
                sampSendChat("/ad 1 Проходит набор в империю Fantasy. Все улучшения, Discord, Беседа в ВК. Звоните/Пишите")
                wait(1000)
            end)
        end
        if imgui.Button(u8 "Выдать рацию") then
            imgui.OpenPopup(u8 "Выдать рацию новому")
            lua_thread.create(function()
                sampSendChat("/me резким движением рук снимает рюкзак с плеча, после чего открывает его", -1)
                wait(1000)
                sampSendChat("/me достает оттуда рацию, передает его человеку")
                wait(1000)
                sampSendChat("/todo Вот бери*улыбаясь", -1)
                wait(1000)
            end)
        end
       
        imgui.Separator()
        imgui.NewLine()
       
        imgui.Text(u8 'Авто - Пиар Fantasy Empire в вип чат')
        if imadd.ToggleButton(u8 "Sprunk##", activeB) then activate = not activate if activate then sampAddChatMessage('{FF69B4}Автопиар успешно включен!', -1) else sampAddChatMessage('{FF69B4}Вы выключили автопиар!', -1) end end
        imgui.SameLine(); imgui.Text(u8 'Нажми на кнопку, если хочешь включить пиар')
    end
   
    imgui.End()
end

function flooder()
    while true do
        if activate then
            sampSendChat("/vr Проходит набор в империю Fantasy. Все улучшения, Discord, Беседа в ВК. Звоните/Пишите")
        end
        wait(300000)
    end
end

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

    style.WindowPadding = imgui.ImVec2(8, 8)
    style.WindowRounding = 6
    style.ChildWindowRounding = 5
    style.FramePadding = imgui.ImVec2(5, 3)
    style.FrameRounding = 3.0
    style.ItemSpacing = imgui.ImVec2(5, 4)
    style.ItemInnerSpacing = imgui.ImVec2(4, 4)
    style.IndentSpacing = 21
    style.ScrollbarSize = 10.0
    style.ScrollbarRounding = 13
    style.GrabMinSize = 8
    style.GrabRounding = 1
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)

    colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 0.95)
    colors[clr.TextDisabled] = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.WindowBg] = ImVec4(0.13, 0.12, 0.12, 1.00)
    colors[clr.ChildWindowBg] = ImVec4(0.13, 0.12, 0.12, 1.00)
    colors[clr.PopupBg] = ImVec4(0.05, 0.05, 0.05, 0.94)
    colors[clr.Border] = ImVec4(0.53, 0.53, 0.53, 0.46)
    colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg] = ImVec4(0.00, 0.00, 0.00, 0.85)
    colors[clr.FrameBgHovered] = ImVec4(0.22, 0.22, 0.22, 0.40)
    colors[clr.FrameBgActive] = ImVec4(0.16, 0.16, 0.16, 0.53)
    colors[clr.TitleBg] = ImVec4(0.00, 0.00, 0.00, 1.00)
    colors[clr.TitleBgActive] = ImVec4(0.00, 0.00, 0.00, 1.00)
    colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.MenuBarBg] = ImVec4(0.12, 0.12, 0.12, 1.00)
    colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab] = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive] = ImVec4(0.48, 0.48, 0.48, 1.00)
    colors[clr.ComboBg] = ImVec4(0.24, 0.24, 0.24, 0.99)
    colors[clr.CheckMark] = ImVec4(0.79, 0.79, 0.79, 1.00)
    colors[clr.SliderGrab] = ImVec4(0.48, 0.47, 0.47, 0.91)
    colors[clr.SliderGrabActive] = ImVec4(0.56, 0.55, 0.55, 0.62)
    colors[clr.Button] = ImVec4(0.50, 0.50, 0.50, 0.63)
    colors[clr.ButtonHovered] = ImVec4(0.67, 0.67, 0.68, 0.63)
    colors[clr.ButtonActive] = ImVec4(0.26, 0.26, 0.26, 0.63)
    colors[clr.Header] = ImVec4(0.54, 0.54, 0.54, 0.58)
    colors[clr.HeaderHovered] = ImVec4(0.64, 0.65, 0.65, 0.80)
    colors[clr.HeaderActive] = ImVec4(0.25, 0.25, 0.25, 0.80)
    colors[clr.Separator] = ImVec4(0.58, 0.58, 0.58, 0.50)
    colors[clr.SeparatorHovered] = ImVec4(0.81, 0.81, 0.81, 0.64)
    colors[clr.SeparatorActive] = ImVec4(0.81, 0.81, 0.81, 0.64)
    colors[clr.ResizeGrip] = ImVec4(0.87, 0.87, 0.87, 0.53)
    colors[clr.ResizeGripHovered] = ImVec4(0.87, 0.87, 0.87, 0.74)
    colors[clr.ResizeGripActive] = ImVec4(0.87, 0.87, 0.87, 0.74)
    colors[clr.CloseButton] = ImVec4(0.45, 0.45, 0.45, 0.50)
    colors[clr.CloseButtonHovered] = ImVec4(0.70, 0.70, 0.90, 0.60)
    colors[clr.CloseButtonActive] = ImVec4(0.70, 0.70, 0.70, 1.00)
    colors[clr.PlotLines] = ImVec4(0.68, 0.68, 0.68, 1.00)
    colors[clr.PlotLinesHovered] = ImVec4(0.68, 0.68, 0.68, 1.00)
    colors[clr.PlotHistogram] = ImVec4(0.90, 0.77, 0.33, 1.00)
    colors[clr.PlotHistogramHovered] = ImVec4(0.87, 0.55, 0.08, 1.00)
    colors[clr.TextSelectedBg] = ImVec4(0.47, 0.60, 0.76, 0.47)
    colors[clr.ModalWindowDarkening] = ImVec4(0.88, 0.88, 0.88, 0.35)
end
black_grey()

function cmd_imgui(arg)
    number_window_state.v = not number_window_state.v
    imgui.Process = number_window_state.v or show_2_window.v
end

function imgui.OnDrawFrame()
    if not isCharInAnyCar(PLAYER_PED) then
        imgui.SetNextWindowPos(imgui.ImVec2(430, 824), imgui.Cond.FirstUseEver)
        imgui.ShowCursor = false
        imgui.SetMouseCursor(-1)
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        server = sampGetCurrentServerName(PLAYER_HANDLE)
        ip = sampGetCurrentServerAddress(PLAYER_PED)
        weap = getCurrentCharWeapon(PLAYER_PED)
        weaponid = getWeapontypeModel(weap)
        ammo = getAmmoInCharWeapon(PLAYER_PED, weap)
        nick = sampGetPlayerNickname(id)
        fFps = mem.getfloat(0xB7CB50, 4, false)  
        ping = sampGetPlayerPing(id)
        time = (os.date("%H",os.time())..':'..os.date("%M",os.time())..':'..os.date("%S",os.time()))
        date = (os.date("%d",os.time())..'/'..os.date("%m",os.time())..'/'..os.date("%Y",os.time()))
        Health = getCharHealth(PLAYER_PED)
        Armor = getCharArmour(PLAYER_PED)
        Level = sampGetPlayerScore(id)
        pspeed = getCharSpeed(PLAYER_PED)
        local online = getGameTimer()/100000
        local afk = os.clock() - online
        x,y,z = getCharCoordinates(PLAYER_PED)
        Hours = (os.date("%H", os.time()))
        Minuts = (os.date("%M", os.time()))
        Seconds = (os.date("%S", os.time()))
        imgui.Begin("INFOBAR | Coded by NNC.", window, imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoResize + imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.ShowBorders)
        imgui.Text("Server: " .. server, main_color)
        imgui.Text("NickName: " .. nick ..  " | ID: " .. id, main_color)
        imgui.Text("Online: " .. online .. " | AFK: " .. afk, main_color)
        imgui.End()
    else
        imgui.SetNextWindowPos(imgui.ImVec2(430, 824), imgui.Cond.FirstUseEver)
        imgui.ShowCursor = false
        imgui.SetMouseCursor(-1)
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        car = storeCarCharIsInNoSave(playerPed)
        carmodel = getCarModel(car)
        carname = getGxtText(getNameOfVehicleModel(carmodel))
        _, cid = sampGetVehicleIdByCarHandle(car)
        carhp = getCarHealth(car)
        cspeed = getCarSpeed(car)
        server = sampGetCurrentServerName(PLAYER_HANDLE)
        ip = sampGetCurrentServerAddress(PLAYER_PED)
        nick = sampGetPlayerNickname(id)
        fFps = mem.getfloat(0xB7CB50, 4, false)  
        ping = sampGetPlayerPing(id)
        time = (os.date("%H",os.time())..':'..os.date("%M",os.time())..':'..os.date("%S",os.time()))
        date = (os.date("%d",os.time())..'/'..os.date("%m",os.time())..'/'..os.date("%Y",os.time()))
        Health = getCharHealth(PLAYER_PED)
        Armor = getCharArmour(PLAYER_PED)
        Hours = (os.date("%H", os.time()))
        Minuts = (os.date("%M", os.time()))
        Seconds = (os.date("%S", os.time()))
        Level = sampGetPlayerScore(id)
        x,y,z = getCharCoordinates(PLAYER_PED)
        imgui.Begin("INFOBAR | Coded by NNC.", window, imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoResize + imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.ShowBorders)
        imgui.Text("Server: " .. server, main_color)
        imgui.Text("NickName: " .. nick ..  " | ID: " .. id, main_color)
        imgui.Text("Ping: " .. ping .. " | Level: " .. Level .. " | FPS: " .. math.floor(fFps), main_color)
        imgui.Text("Time: " .. time .. " | Date: " .. date, main_color)
        imgui.Text("City: " .. city[getCityPlayerIsIn(PLAYER_HANDLE)] .. " | PlayerTime: " .. playhours .. ":" .. playmin .. ":" .. playsec, main_color)
        imgui.Text("Health: " .. Health .. " | Armour: " .. Armor .. " | Speed: " .. math.floor(cspeed * 2.5), main_color)
        imgui.Text("CarHP: " .. carhp .. " | CarID: " .. cid .. " | CarType: " .. carmodel, main_color)
        imgui.Text("X: " .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z), main_color)
        imgui.End()  
    end
end
Не могли бы подсказать в чем проблема?
Одна команда зарегистрирована в двух разных скриптах? Так работать не будет
 

advancerp

Известный
77
5
как сделать, чтобы, когда я афк, скрипт не отслеживал сообщения в чате и после выхода из афк не выполнял действия, которые выполняются после найденного сообщения?
 

CaJlaT

Овощ
Модератор
2,808
2,613
как сделать, чтобы, когда я афк, скрипт не отслеживал сообщения в чате и после выхода из афк не выполнял действия, которые выполняются после найденного сообщения?
Проверку на паузу сделай
Lua:
if not isGamePaused() then
    --code
end
 
  • Нравится
Реакции: S.Walston

S.Walston

Новичок
22
1
C++:
----------------------------------------------------------------------------------------

local limgui, imgui = pcall(require, 'imgui') assert(limgui, 'Library \'imgui\' not found.')
local limadd, imadd = pcall(require, 'imgui_addons') assert(limadd, 'Library \'imgui_addons\' not found.')
local lencoding, encoding = pcall(require, 'encoding') assert(lencoding, 'Library \'encoding\' not found.')

----------------------------------------------------------------------------------------

encoding.default = 'CP1251'
local u8 = encoding.UTF8
local sampev = require 'lib.samp.events'
local active = true
local mem = require 'memory'
local main_color = 0xFFFFFF
local tag = "{FFD700}[INFOBAR]:"
local keys = require 'vkeys'
local playsec = 0
local playmin = 0
local playhours = 0
local tables
local imgui = require 'imgui'
local encoding = require 'encoding'

----------------------------------------------------------------------------------------

activate = false

----------------------------------------------------------------------------------------

local window = imgui.ImBool(false)
local number_linux_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

----------------------------------------------------------------------------------------

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("[Fantasy] Скрипт загружен. Специально для Fantasy Empire", 0xFFd86bf3)
    sampAddChatMessage("[Fantasy] Версия скрипта: v1.0", 0xFFd86bf3)
    sampRegisterChatCommand("poisk", function ()
        window.v = not window.v
    end)
    lua_thread.create(flooder)
    while true do
        wait(0)
            playsec = playsec + 1
            if playsec == 60 and playmin then
                playmin = playmin + 1
                playsec = 0
            end
            if playmin == 60 then
                playhours = playhours + 1
                playmin = 0
            end
        if number_linux_state.v == false then
        imgui.Process = true
        end
        imgui.Process = window.v
    end
    wait(-1)
end

function cmd_imgui(arg)
    number_linux_state.v = not number_linux_state.v
    imgui.Process = number_linux_state.v or show_2_winow.v
end

function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-0.1, 0)
    activeB = imgui.ImBool(activate)
    
    if not window.v and not number_linux_state.v then
        imgui.process = false
    end
    
    if window.v then
        
        imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth / 2, iScreenHeight / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(500, 350), imgui.Cond.FirstUseEver)
      
        imgui.Begin(u8"Fantasy Empire", window, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        
        imgui.Separator()
        
        if imgui.Button(u8 "Пиар семья 1 кликом!") then
            imgui.OpenPopup(u8 "Пиар семьи в радио и вип")
            lua_thread.create(function()
                sampSendChat("/vr Проходит набор в империю Fantasy. Все улучшения, Discord, Беседа в ВК. Звоните/Пишите", -1)
                wait(1000)
                sampSendChat("/ad 1 Проходит набор в империю Fantasy. Все улучшения, Discord, Беседа в ВК. Звоните/Пишите")
                wait(1000)
            end)
        end
        if imgui.Button(u8 "Выдать рацию") then
            imgui.OpenPopup(u8 "Выдать рацию новому")
            lua_thread.create(function()
                sampSendChat("/me резким движением рук снимает рюкзак с плеча, после чего открывает его", -1)
                wait(1000)
                sampSendChat("/me достает оттуда рацию, передает его человеку")
                wait(1000)
                sampSendChat("/todo Вот бери*улыбаясь", -1)
                wait(1000)
            end)
        end
        
        imgui.Separator()
        imgui.NewLine()
        
        imgui.Text(u8 'Авто - Пиар Fantasy Empire в вип чат')
        if imadd.ToggleButton(u8 "Sprunk##", activeB) then activate = not activate if activate then sampAddChatMessage('{FF69B4}Автопиар успешно включен!', -1) else sampAddChatMessage('{FF69B4}Вы выключили автопиар!', -1) end end
        imgui.SameLine(); imgui.Text(u8 'Нажми на кнопку, если хочешь включить пиар')
    end
    
    imgui.End()
end
        
        if number_linux_state.v then
        
        if not isCharInAnyCar(PLAYER_PED) then
        imgui.SetNextWindowPos(imgui.ImVec2(430, 824), imgui.Cond.FirstUseEver)
        imgui.ShowCursor = false
        imgui.SetMouseCursor(-1)
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        server = sampGetCurrentServerName(PLAYER_HANDLE)
        ip = sampGetCurrentServerAddress(PLAYER_PED)
        weap = getCurrentCharWeapon(PLAYER_PED)
        weaponid = getWeapontypeModel(weap)
        ammo = getAmmoInCharWeapon(PLAYER_PED, weap)
        nick = sampGetPlayerNickname(id)
        fFps = mem.getfloat(0xB7CB50, 4, false)   
        ping = sampGetPlayerPing(id)
        time = (os.date("%H",os.time())..':'..os.date("%M",os.time())..':'..os.date("%S",os.time()))
        date = (os.date("%d",os.time())..'/'..os.date("%m",os.time())..'/'..os.date("%Y",os.time()))
        Health = getCharHealth(PLAYER_PED)
        Armor = getCharArmour(PLAYER_PED)
        Level = sampGetPlayerScore(id)
        pspeed = getCharSpeed(PLAYER_PED)
        local online = getGameTimer()/100000
        local afk = os.clock() - online
        x,y,z = getCharCoordinates(PLAYER_PED)
        Hours = (os.date("%H", os.time()))
        Minuts = (os.date("%M", os.time()))
        Seconds = (os.date("%S", os.time()))
        imgui.Begin("INFOBAR | Coded by NNC.", window, imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoResize + imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.ShowBorders)
        imgui.Text("Server: " .. server, main_color)
        imgui.Text("NickName: " .. nick ..  " | ID: " .. id, main_color)
        imgui.Text("Online: " .. online .. " | AFK: " .. afk, main_color)
        imgui.End()
    else
        imgui.SetNextWindowPos(imgui.ImVec2(430, 824), imgui.Cond.FirstUseEver)
        imgui.ShowCursor = false
        imgui.SetMouseCursor(-1)
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        car = storeCarCharIsInNoSave(playerPed)
        carmodel = getCarModel(car)
        carname = getGxtText(getNameOfVehicleModel(carmodel))
        _, cid = sampGetVehicleIdByCarHandle(car)
        carhp = getCarHealth(car)
        cspeed = getCarSpeed(car)
        server = sampGetCurrentServerName(PLAYER_HANDLE)
        ip = sampGetCurrentServerAddress(PLAYER_PED)
        nick = sampGetPlayerNickname(id)
        fFps = mem.getfloat(0xB7CB50, 4, false)   
        ping = sampGetPlayerPing(id)
        time = (os.date("%H",os.time())..':'..os.date("%M",os.time())..':'..os.date("%S",os.time()))
        date = (os.date("%d",os.time())..'/'..os.date("%m",os.time())..'/'..os.date("%Y",os.time()))
        Health = getCharHealth(PLAYER_PED)
        Armor = getCharArmour(PLAYER_PED)
        Hours = (os.date("%H", os.time()))
        Minuts = (os.date("%M", os.time()))
        Seconds = (os.date("%S", os.time()))
        Level = sampGetPlayerScore(id)
        x,y,z = getCharCoordinates(PLAYER_PED)
        imgui.Begin("INFOBAR | Coded by NNC.", window, imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoResize + imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.ShowBorders)
        imgui.Text("Server: " .. server, main_color)
        imgui.Text("NickName: " .. nick ..  " | ID: " .. id, main_color)
        imgui.Text("Ping: " .. ping .. " | Level: " .. Level .. " | FPS: " .. math.floor(fFps), main_color)
        imgui.Text("Time: " .. time .. " | Date: " .. date, main_color)
        imgui.Text("City: " .. city[getCityPlayerIsIn(PLAYER_HANDLE)] .. " | PlayerTime: " .. playhours .. ":" .. playmin .. ":" .. playsec, main_color)
        imgui.Text("Health: " .. Health .. " | Armour: " .. Armor .. " | Speed: " .. math.floor(cspeed * 2.5), main_color)
        imgui.Text("CarHP: " .. carhp .. " | CarID: " .. cid .. " | CarType: " .. carmodel, main_color)
        imgui.Text("X: " .. math.floor(x) .. " | Y: " .. math.floor(y) .. " | Z: " .. math.floor(z), main_color)
    end
    
    imgui.End()
end

function flooder()
    while true do
        if activate then
            sampSendChat("/vr Проходит набор в империю Fantasy. Все улучшения, Discord, Беседа в ВК. Звоните/Пишите")
        end
        wait(300000)
    end
end

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

    style.WindowPadding = imgui.ImVec2(8, 8)
    style.WindowRounding = 6
    style.ChildWindowRounding = 5
    style.FramePadding = imgui.ImVec2(5, 3)
    style.FrameRounding = 3.0
    style.ItemSpacing = imgui.ImVec2(5, 4)
    style.ItemInnerSpacing = imgui.ImVec2(4, 4)
    style.IndentSpacing = 21
    style.ScrollbarSize = 10.0
    style.ScrollbarRounding = 13
    style.GrabMinSize = 8
    style.GrabRounding = 1
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)

    colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 0.95)
    colors[clr.TextDisabled] = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.WindowBg] = ImVec4(0.13, 0.12, 0.12, 1.00)
    colors[clr.ChildWindowBg] = ImVec4(0.13, 0.12, 0.12, 1.00)
    colors[clr.PopupBg] = ImVec4(0.05, 0.05, 0.05, 0.94)
    colors[clr.Border] = ImVec4(0.53, 0.53, 0.53, 0.46)
    colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg] = ImVec4(0.00, 0.00, 0.00, 0.85)
    colors[clr.FrameBgHovered] = ImVec4(0.22, 0.22, 0.22, 0.40)
    colors[clr.FrameBgActive] = ImVec4(0.16, 0.16, 0.16, 0.53)
    colors[clr.TitleBg] = ImVec4(0.00, 0.00, 0.00, 1.00)
    colors[clr.TitleBgActive] = ImVec4(0.00, 0.00, 0.00, 1.00)
    colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.MenuBarBg] = ImVec4(0.12, 0.12, 0.12, 1.00)
    colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab] = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive] = ImVec4(0.48, 0.48, 0.48, 1.00)
    colors[clr.ComboBg] = ImVec4(0.24, 0.24, 0.24, 0.99)
    colors[clr.CheckMark] = ImVec4(0.79, 0.79, 0.79, 1.00)
    colors[clr.SliderGrab] = ImVec4(0.48, 0.47, 0.47, 0.91)
    colors[clr.SliderGrabActive] = ImVec4(0.56, 0.55, 0.55, 0.62)
    colors[clr.Button] = ImVec4(0.50, 0.50, 0.50, 0.63)
    colors[clr.ButtonHovered] = ImVec4(0.67, 0.67, 0.68, 0.63)
    colors[clr.ButtonActive] = ImVec4(0.26, 0.26, 0.26, 0.63)
    colors[clr.Header] = ImVec4(0.54, 0.54, 0.54, 0.58)
    colors[clr.HeaderHovered] = ImVec4(0.64, 0.65, 0.65, 0.80)
    colors[clr.HeaderActive] = ImVec4(0.25, 0.25, 0.25, 0.80)
    colors[clr.Separator] = ImVec4(0.58, 0.58, 0.58, 0.50)
    colors[clr.SeparatorHovered] = ImVec4(0.81, 0.81, 0.81, 0.64)
    colors[clr.SeparatorActive] = ImVec4(0.81, 0.81, 0.81, 0.64)
    colors[clr.ResizeGrip] = ImVec4(0.87, 0.87, 0.87, 0.53)
    colors[clr.ResizeGripHovered] = ImVec4(0.87, 0.87, 0.87, 0.74)
    colors[clr.ResizeGripActive] = ImVec4(0.87, 0.87, 0.87, 0.74)
    colors[clr.CloseButton] = ImVec4(0.45, 0.45, 0.45, 0.50)
    colors[clr.CloseButtonHovered] = ImVec4(0.70, 0.70, 0.90, 0.60)
    colors[clr.CloseButtonActive] = ImVec4(0.70, 0.70, 0.70, 1.00)
    colors[clr.PlotLines] = ImVec4(0.68, 0.68, 0.68, 1.00)
    colors[clr.PlotLinesHovered] = ImVec4(0.68, 0.68, 0.68, 1.00)
    colors[clr.PlotHistogram] = ImVec4(0.90, 0.77, 0.33, 1.00)
    colors[clr.PlotHistogramHovered] = ImVec4(0.87, 0.55, 0.08, 1.00)
    colors[clr.TextSelectedBg] = ImVec4(0.47, 0.60, 0.76, 0.47)
    colors[clr.ModalWindowDarkening] = ImVec4(0.88, 0.88, 0.88, 0.35)
end
black_grey()
Приветствую всех, не могли бы подсказать, почему number_linux_state не включается при запуске скрипта?
 

Dmitriy Makarov

25.05.2021
Проверенный
2,480
1,113
Приветствую всех, не могли бы подсказать, почему number_linux_state не включается при запуске скрипта?
Ну наверное потому что там значение false стоит. =)
Попробуй на true поменять.
local number_linux_state = imgui.ImBool(true)
 

shizzard

Участник
150
7
Добавить сохранение inicfg.save
После inicfg.save, я знаю что сохранять надо😆,, проблема в том что не сохраняет
Lua:
require "lib.moonloader"
local themes = import 'lib/imgui_themes.lua'
local tag = '{3498DB}[Игнорщик]: '
local color =  0x3498DB--0xFF69B4
local red_color = 0xff0040
ftext = function(text)
    sampAddChatMessage('[Игнорщик]: {ffffff}'..text,0x3498DB)
end
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local sampev = require 'lib.samp.events'
local imgui = require 'imgui'
local buffer = imgui.ImBuffer(32)
local cbuffer = imgui.ImBuffer(32)
local mainmenu = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local inicfg = require 'inicfg'
local directIni = "moonloader\\config\\ignore.ini"
local mainIni = inicfg.load({
    imessage = {
        itext = ' ',
        cmd = (cbuffer.v),
    }
})
local cmdmenu = {
    v = decodeJson(mainIni.imessage.cmd)
}
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
        if not doesFileExist('ignore.ini') then inicfg.save(mainIni,'ignore.ini') end
        local _, myid = sampGetPlayerIdByCharHandle(PLAYER_PED)
        local nick = sampGetPlayerNickname(select(2, sampGetPlayerIdByCharHandle(1))):gsub('_', ' ')
        ftext('Добро пожаловать ' .. nick .. '!')
        ftext('Автор скрипта: Steven Eaton.')
        ftext('Активация : /ig')
        imgui.Process = False
        if mainIni.imessage.cmd == '' or mainIni.imessage.cmd == ' '    then
            sampRegisterChatCommand('ig', mainmenuf)
        else
            sampUnregisterChatCommand('ig')
            sampRegisterChatCommand(mainIni.imessage.cmd, mainmenuf)
        end
        imgui.SwitchContext()
        themes.SwitchColorTheme()
    while true do
            imgui.Process = mainmenu.v
    wait(0)
    end
end
function mainmenuf(args)
    mainmenu.v = not mainmenu.v
    imgui.Process = mainmenu.v
end
function imgui.OnDrawFrame()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5)) imgui.SetNextWindowSize(imgui.ImVec2(725, 340), imgui.Cond.FirstUseEver)
        if mainmenu.v then
                imgui.Begin(u8"Игнорщик v24".. ' ' ..os.date("%d.%m.%Y"), mainmenu, imgui.WindowFlags.NoResize)
                imgui.PushItemWidth(150)
        --[[        if     imgui.InputText(u8'1 требование', buffer1) then
                        mainIni.trebovania.treb1 = buffer1.v
                        inicfg.save(mainIni, directIni)
                    end]]
                imgui.InputText(u8'Вводите текст или часть текста которую хотите игнорировать',buffer)
                if imgui.InputText(u8'Сменить команду активации', cbuffer) then
                    mainIni.imessage.cmd = cbuffer.v
                    inicfg.save(mainIni,directIni)
                end
            imgui.SameLine()
            if imgui.Button(u8'Сохранить команду') then
                mainIni.imessage.cmd = cbuffer.v
                inicfg.save(mainIni, directIni)
                if cbuffer.v == nil or cbuffer.v == '' or cbuffer.v == ' ' then
                    ftext('Поле ввода пустое, введите команду без "/" ')
                else
                ftext(mainIni.imessage.cmd)
            end
        end
            imgui.SameLine()
        if not mainIni.imessage.cmd == '' or ' ' then
            sampUnregisterChatCommand('ig')
            sampRegisterChatCommand(mainIni.imessage.cmd, mainmenuf)
                imgui.Text(mainIni.imessage.cmd)
            else
                imgui.Text('/ig')
            end
--[[if mainIni.imessage.cmd == ' ' or '' then
    imgui.Text(u8'(Сейчас: /ig)')
elseif
    imgui.Text('Сейчас: /' .. u8(mainIni.imessage.cmd))
end]]
                imgui.End()
            end
end
до перезапуска в кфг сохраняется, после ничего нету
 

Fott

Простреленный
3,436
2,280
После inicfg.save, я знаю что сохранять надо😆,, проблема в том что не сохраняет
Lua:
require "lib.moonloader"
local themes = import 'lib/imgui_themes.lua'
local tag = '{3498DB}[Игнорщик]: '
local color =  0x3498DB--0xFF69B4
local red_color = 0xff0040
ftext = function(text)
    sampAddChatMessage('[Игнорщик]: {ffffff}'..text,0x3498DB)
end
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local sampev = require 'lib.samp.events'
local imgui = require 'imgui'
local buffer = imgui.ImBuffer(32)
local cbuffer = imgui.ImBuffer(32)
local mainmenu = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local inicfg = require 'inicfg'
local directIni = "moonloader\\config\\ignore.ini"
local mainIni = inicfg.load({
    imessage = {
        itext = ' ',
        cmd = (cbuffer.v),
    }
})
local cmdmenu = {
    v = decodeJson(mainIni.imessage.cmd)
}
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
        if not doesFileExist('ignore.ini') then inicfg.save(mainIni,'ignore.ini') end
        local _, myid = sampGetPlayerIdByCharHandle(PLAYER_PED)
        local nick = sampGetPlayerNickname(select(2, sampGetPlayerIdByCharHandle(1))):gsub('_', ' ')
        ftext('Добро пожаловать ' .. nick .. '!')
        ftext('Автор скрипта: Steven Eaton.')
        ftext('Активация : /ig')
        imgui.Process = False
        if mainIni.imessage.cmd == '' or mainIni.imessage.cmd == ' '    then
            sampRegisterChatCommand('ig', mainmenuf)
        else
            sampUnregisterChatCommand('ig')
            sampRegisterChatCommand(mainIni.imessage.cmd, mainmenuf)
        end
        imgui.SwitchContext()
        themes.SwitchColorTheme()
    while true do
            imgui.Process = mainmenu.v
    wait(0)
    end
end
function mainmenuf(args)
    mainmenu.v = not mainmenu.v
    imgui.Process = mainmenu.v
end
function imgui.OnDrawFrame()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5)) imgui.SetNextWindowSize(imgui.ImVec2(725, 340), imgui.Cond.FirstUseEver)
        if mainmenu.v then
                imgui.Begin(u8"Игнорщик v24".. ' ' ..os.date("%d.%m.%Y"), mainmenu, imgui.WindowFlags.NoResize)
                imgui.PushItemWidth(150)
        --[[        if     imgui.InputText(u8'1 требование', buffer1) then
                        mainIni.trebovania.treb1 = buffer1.v
                        inicfg.save(mainIni, directIni)
                    end]]
                imgui.InputText(u8'Вводите текст или часть текста которую хотите игнорировать',buffer)
                if imgui.InputText(u8'Сменить команду активации', cbuffer) then
                    mainIni.imessage.cmd = cbuffer.v
                    inicfg.save(mainIni,directIni)
                end
            imgui.SameLine()
            if imgui.Button(u8'Сохранить команду') then
                mainIni.imessage.cmd = cbuffer.v
                inicfg.save(mainIni, directIni)
                if cbuffer.v == nil or cbuffer.v == '' or cbuffer.v == ' ' then
                    ftext('Поле ввода пустое, введите команду без "/" ')
                else
                ftext(mainIni.imessage.cmd)
            end
        end
            imgui.SameLine()
        if not mainIni.imessage.cmd == '' or ' ' then
            sampUnregisterChatCommand('ig')
            sampRegisterChatCommand(mainIni.imessage.cmd, mainmenuf)
                imgui.Text(mainIni.imessage.cmd)
            else
                imgui.Text('/ig')
            end
--[[if mainIni.imessage.cmd == ' ' or '' then
    imgui.Text(u8'(Сейчас: /ig)')
elseif
    imgui.Text('Сейчас: /' .. u8(mainIni.imessage.cmd))
end]]
                imgui.End()
            end
end
до перезапуска в кфг сохраняется, после ничего нету
Пробуй так
Lua:
local themes = import 'lib/imgui_themes.lua'
local tag = '{3498DB}[Хелпер Похиток]: '
local color =  0x3498DB--0xFF69B4
local red_color = 0xff0040
local berserk = 1
local imgui = require 'imgui'
local cbuffer = imgui.ImInt(0)
local buffer1 = imgui.ImBuffer(256)
local buffer2 = imgui.ImBuffer(256)
local buffer3 = imgui.ImBuffer(256)
local buffer4 = imgui.ImBuffer(256)
local buffer5 = imgui.ImBuffer(256)
local combobombo1 = imgui.ImInt(0)
local combobombo = imgui.ImInt(0)
font2 = renderCreateFont('Arial', 8, 5)
ftext = function(text)
    sampAddChatMessage('[Хелпер Похиток]: {ffffff}'..text,0x3498DB)
end
local inicfg = require 'inicfg'
    local mainIni = inicfg.load({
    hotkey = {
    bindr = encodeJson({ VK_R, VK_ALT }),
    bindrb = encodeJson({ VK_Q, VK_ALT }),
    bindst = encodeJson({VK_O,VK_ALT}),
    bindt = encodeJson({VK_A,VK_ALT})
    },
    itheme = {
        theme = encodeJson({themes.SwitchColorTheme(0)}),
    },
    trebovania = {
         treb1 = encodeJson({buffer1.v}),
         treb2 = encodeJson({buffer2.v}),
         treb3 = encodeJson({buffer3.v}),
         treb4 = encodeJson({buffer4.v}),
         treb5 = encodeJson({buffer5.v}),
         tclist = encodeJson(cbuffer.v)
    }
},'px.ini')
require 'lib.moonloader'

local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local rkeys = require 'rkeys'
imgui.HotKey =  require('imgui_addons').HotKey
imgui.ToggleButton = require('imgui_addons').ToggleButton
local sampev = require 'lib.samp.events'
local tLastKeys = {}
local imBool = imgui.ImBool(false)
local ThemeMenu = {
    v = decodeJson(mainIni.itheme.theme)
}
local TrebMenu1 = {
    v = decodeJson(mainIni.trebovania.treb1)
}
local TrebMenu2 = {
    v = decodeJson(mainIni.trebovania.treb2)
}
local TrebMenu3 = {
    v = decodeJson(mainIni.trebovania.treb3)
}
local TrebMenu4 = {
    v = decodeJson(mainIni.trebovania.treb4)
}
local TrebMenu5 = {
    v = decodeJson(mainIni.trebovania.treb5)
}
local ActiveClockMenu = {
    v = decodeJson(mainIni.hotkey.bindr)
}
local ActiveClockMenu1 = {
    v = decodeJson(mainIni.hotkey.bindrb)
}
local ActiveClockMenu2 = {
    v = decodeJson(mainIni.hotkey.bindst)
}
local ActiveClockMenu3 = {
    v = decodeJson(mainIni.hotkey.bindt)
}
if not doesFileExist('moonloader\\px.ini') then inicfg.save(mainIni,'px.ini') end
local bt = 0
local rt =2
local pt = 6
local bt = 5
local key = 20000
local agent_window_state = imgui.ImBool(false)
local rasc_window_state = imgui.ImBool(false)
local poxititel_window_state = imgui.ImBool(false)
local extra_window_state = imgui.ImBool(false)
local extra_extra_window_state = imgui.ImBool(false)
local text_buffer_name = imgui.ImBuffer(256)
local min = imgui.ImInt(10)
local timer = 0
local priezd = imgui.ImBuffer(64)
local priezds = imgui.ImBuffer(64)
local combo = imgui.ImInt(0)
local combo1 = imgui.ImInt(0)
local combo2 = imgui.ImInt(0)
local combo3 = imgui.ImInt(0)
local combo4 = imgui.ImInt(0)
local pcombo = imgui.ImInt(0)
local pcombo1 = imgui.ImInt(0)
local pcombo2 = imgui.ImInt(0)
local pcombo3 = imgui.ImInt(0)
local pcombo4 = imgui.ImInt(0)
local sw, sh = getScreenResolution()
local combobombo = imgui.ImInt(0)
local combobombo1 = imgui.ImInt(0)
local pfbi =
                {
' ' ,u8'Стажёр', u8'Дежурный', u8'Мл.Агент',u8'Агент DEA',u8'Агент CID',u8'Глава DEA',u8'Глава CID',u8'Инспектор FBI',u8'Зам.Директора FBI',u8'Директор FBI'
            }
local checkfrac ={
    ' ',u8'Мэрия',u8'SAPD',u8'Медики',u8'Армия',u8'ФБР',u8'Автошколаы'
}
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
        local _, myid = sampGetPlayerIdByCharHandle(PLAYER_PED)
        local nick = sampGetPlayerNickname(select(2, sampGetPlayerIdByCharHandle(1))):gsub('_', ' ')
        sampAddChatMessage(tag .. '{FFFFFF}Добро пожаловать, '.. nick ..'.',color)
        sampAddChatMessage(tag .. '{FFFFFF}Автор : Steven Eaton. Приятной игры', color)
        sampAddChatMessage(tag .. '{FFFFFF}Активация : /px', color)
        sampAddChatMessage(tag .. '{FFFFFF}Отдельное спасибо {ff0040}ronnyevans', color)
    sampRegisterChatCommand("px3249234", poxitka)
        sampRegisterChatCommand(px230423402, poxitka2)
        sampRegisterChatCommand("px", poxitka1)
        sampRegisterChatCommand(aksodasidjasd, funcfunc)
        sampRegisterChatCommand(zhaohpgasdogijasdf, gerald)
        imgui.Process = False
        imgui.SwitchContext()
        themes.SwitchColorTheme()
        bindr = rkeys.registerHotKey(ActiveClockMenu.v, true, rhot)
        bindrb = rkeys.registerHotKey(ActiveClockMenu1.v, true, rbhot)
        bindst = rkeys.registerHotKey(ActiveClockMenu2.v, true, bindst)
                bindt = rkeys.registerHotKey(ActiveClockMenu3.v, true, bindt)
        themes.SwitchColorTheme(mainIni.itheme.theme)
      while true do
imgui.Process = extra_window_state.v -- window поменяй на свою переменную
                wait(0)
            end
        end
        function rhot(args)
            if buffer1.v == '' and buffer2.v == '' and buffer3.v == '' and buffer4.v == ''and  buffer5.v == '' then
                    sampAddChatMessage(tag .. '{FFFFFF}Нет требовании, введите их в поля требовании.', color)
            else
                    sampAddChatMessage(tag..(u8:decode(buffer1.v)).. ' ' .. (u8:decode(buffer2.v)) .. ' ' .. (u8:decode(buffer3.v)) ..' ' .. (u8:decode(buffer4.v)) .. ' ' .. (u8:decode(buffer5.v)), red_color)
            end
    end
        function rbhot(args)
            if mainIni.trebovania.treb1 == ' ' and mainIni.trebovania.treb2 == ' ' and mainIni.trebovania.treb3 == ' ' and mainIni.trebovania.treb4 == ' ' and  mainIni.trebovania.treb5 == ' '  or  mainIni.trebovania.treb1 == '' and mainIni.trebovania.treb2 == '' and mainIni.trebovania.treb3 == '' and mainIni.trebovania.treb4 == '' and  mainIni.trebovania.treb5 == ' ' then
                sampAddChatMessage(tag .. '{FFFFFF}Нет требовании, введите их в поля требовании.', color)
        else
                sampAddChatMessage(tag..(u8:decode(buffer1.v)).. ' ' .. (u8:decode(buffer2.v)) .. ' ' .. (u8:decode(buffer3.v)) ..' ' .. (u8:decode(buffer4.v)) .. ' ' .. (u8:decode(buffer5.v)), red_color)
        end

        function bindst(args)
          if  mainIni.trebovania.treb1 == ' ' and mainIni.trebovania.treb2 == ' ' and mainIni.trebovania.treb3 == ' ' and mainIni.trebovania.treb4 == ' ' and  mainIni.trebovania.treb5 == ' '  or mainIni.trebovania.treb1 == '' and mainIni.trebovania.treb2 == '' and mainIni.trebovania.treb3 == '' and mainIni.trebovania.treb4 == '' and  mainIni.trebovania.treb5 == ' ' then
                sampAddChatMessage(tag .. '{FFFFFF}Нет требовании, введите их в поля требовании.', color)
            else
                sampAddChatMessage(tag..(u8:decode(buffer1.v)).. ' ' .. (u8:decode(buffer2.v)) .. ' ' .. (u8:decode(buffer3.v)) ..' ' .. (u8:decode(buffer4.v)) .. ' ' .. (u8:decode(buffer5.v)), red_color)
            end
        end


        function sampev.onServerMessage(color,text)
            if text:find('hrt code 3 (%d+)') then
                code = text:match('hrt code 3 (%d+)')
                sampAddChatMessage('code == '.. code, color)
            end
        end
        function sampev.onServerMessage(color, text)
    if text:find('The') then
            sampAddChatMessage('poprobui etot code', color)
        end
end
function sampev.onServerMessage(args)
    if text:find('[Ошибка] На сервере нету свободных мест для загрузки транспорта! Попробуйте позже') then
        ftext('hi')
end
        function imgui.TextQuestion(text)
            imgui.TextDisabled('(?)')
            if imgui.IsItemHovered() then
              imgui.BeginTooltip()
              imgui.PushTextWrapPos(450)
              imgui.TextUnformatted(text)
              imgui.PopTextWrapPos()
              imgui.EndTooltip()
            end
        end
function poxitka(args)
agent_window_state.v = not agent_window_state.v
imgui.Process = agent_window_state.v
end
function poxitka1(args)
extra_window_state.v = not extra_window_state.v
imgui.Process = extra_window_state.v
end
function poxitka(args)
poxititel_window_state.v = not poxititel_window_state.v
imgui.Process = poxititel_window_state.v
end
function imgui.OnDrawFrame()
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5)) imgui.SetNextWindowSize(imgui.ImVec2(725, 340), imgui.Cond.FirstUseEver) -- размер
--    imgui.Begin(u8'Хелпер для похиток', show_main_window, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders)
    --imgui.SetNextWindowSize(imgui.ImVec2(500,300),imgui.Cond.FirstUseEver)
    --imgui.SetNextWindowPos(imgui.ImVec2((sw/2),sh/2),imgui.Cond.FirstUseEver, imgui.ImVec2(0.5,0.5))
    if agent_window_state.v then
            imgui.Begin(u8"Хелпер для похиток v24".. ' ' ..os.date("%d.%m.%Y"), agent_window_state, imgui.WindowFlags.NoResize)
        --[[ = {u8'Цветы ',u8'Трость ',u8 "Бургер ",u8 "Пицца ", u8"Рем.комплект " , u8"2 рем.комплекта " , u8"3 рем.комплекта ", u8"Фотоаппарат ", u8"Пиво "}
        --povyazka = {u8'Красная повязка',u8"Синяя повязка", u8'Зеленая повязка', u8"Черная повязка",u8"Фиолетовая повязка"}
        --chislo = {'1 ', '2 ', '3 '}
    --    colors = {[1] = u8"Синяя", [2] =  "Красная", [3] =  "Коричневая", [4] = "Аква",[5] = "Чёрная", [6] = "Фиолетовая",[7] = "Черно-оранжевая"}
        --imgui.Begin(u8'Хелпер для похиток', agent_window_state)
        --imgui.Combo(u8'Количество',combo_select , chislo )
        -- imgui.Combo(u8'Выберите тему',combo_select, colors )
    --[[    imgui.PushItemWidth(150)
      imgui.Combo(u8'1 требование',combo , )
        imgui.SameLine()
        imgui.Combo(u8'Повязка', cpovyazka, povyazka)
        imgui.PushItemWidth(150)
        imgui.Combo(u8'2 требование',combo1 , )
        imgui.PushItemWidth(150)
        imgui.Combo(u8'3 требование',combo2 , )
        imgui.PushItemWidth(150)
        imgui.Combo(u8'4 требование',combo3 , )
        imgui.PushItemWidth(150)
        imgui.Combo(u8'5 требование',combo4 , )
        imgui.PushItemWidth(250)]]
        imgui.BeginChild("##firstchild", imgui.ImVec2(715, 180), true)
        local checkfrac ={u8' ', u8'Мэрия',u8'SAPD',u8'Медики',u8'Армия',u8'ФБР',u8'Автошкола',u8'Новости'}
        local pfbi ={u8' ', u8'Стажёр', u8'Дежурный', u8'Мл.Агент',u8'Агент DEA',u8'Агент CID',u8'Глава DEA',u8'Глава CID',u8'Инспектор FBI',u8'Зам.Директора FBI',u8'Директор FBI'}
        local pmed = {u8' ',u8'Интерн',u8'Санитар',u8'Мед.Брат',u8'Спасатель',u8'Нарколог',u8'Доктор',u8'Психолог',u8'Хирург',u8'Зам.Глав.Врача',u8'Глав.Врач'}
        local parmy = {u8" " , u8"Рядовой", u8"Ефрейтор",u8"Мл.Сержант",u8"Сержант",u8"Ст.Сержант",u8"Старшина",u8"Прапорщик",u8"Мл.Лейтенант",u8"Лейтенант",u8"Ст.Лейтенант",u8"Капитан",u8"Майор",u8"Подполковник",u8"Полковник",u8"Генерал"}
        local ppd = {u8' ',u8"Кадет", u8"Офицер",u8"Мл.Сержант",u8"Сержант",u8"Прапорщик",u8"Ст.Прапорщик",u8"Мл.Лейтенант",u8"Лейтенант",u8"Ст.Лейтенант",u8"Капитан",u8"Майор",u8"Подполковник",u8"Полковник",u8"Шериф"}
        local pmayor = {u8" ",u8"Секретарь",u8"Адвокат",u8"Охранник",u8"Нач.Охраны",u8"Зам.Мэра",u8"Мэр"}
        local pds = {u8" ",u8"Стажер",u8"Консультант",u8"Экзаменатор",u8"Мл.Инструктор",u8"Инструктор",u8"Координатор",u8"Мл.Менеджер",u8"Ст.Менеджер",u8"Директор",u8"Управляющий",}
        local pnews = {u8'',u8'Стажер',u8'Звукооператор',u8'Звукорежиссер',u8'Репортер',u8'Ведущий',u8'Редактор',u8'Гл.Редактор',u8'Тех.Директор',u8'Програмный Директор',u8'Ген.Директор', }

--[[
pfbi[1] = 70000,
pfbi[2] = 70000,
pfbi[3] = 70000,
pfbi[4] = 80000,
pfbi[5] = 80000,
pfbi[6] = 90000,
pfbi[7] = 90000,
pfbi[8] = 100000,
pfbi[9] = 100000,
pfbi[10] = 150000,

pds[1] = 20000,
pds[2] = 30000,
pds[3] = 40000,
pds[4] = 50000,
pds[5] = 60000,
pds[6] = 70000,
pds[7] = 80000,
pds[8] = 90000,
pds[9] = 100000,
pds[10] = 150000,

pnews[1] = 10000,
pnews[2] = 20000,
pnews[3] = 30000,
pnews[4] = 40000,
pnews[5] = 50000,
pnews[6] = 60000,
pnews[7] = 70000,
pnews[8] = 80000,
pnews[9] = 90000,
pnews[10] = 100000,

pmed[1] = 20000,
pmed[2] = 30000,
pmed[3] = 40000,
pmed[4] = 50000,
pmed[5] = 60000,
pmed[6] = 70000,
pmed[7] = 80000,
pmed[8] = 90000,
pmed[9] = 100000,
pmed[10] = 150000,

parmy[1] = 30000,
parmy[2] = 40000,
parmy[3] = 50000,
parmy[4] = 60000,
parmy[5] = 60000,
parmy[6] = 70000,
parmy[7] = 70000,
parmy[8] = 80000,
parmy[9] = 80000,
parmy[10] = 90000,
parmy[11] = 90000,
parmy[12] = 100000,
parmy[13] = 100000,
parmy[14] = 100000,
parmy[15] = 150000,

pmayor[1] = 20000,
pmayor[2] = 40000,
pmayor[3] = 60000,
pmayor[4] = 80000,
pmayor[5] = 100000,
pmayor[6] = 150000,

ppd[1] = 50000,
ppd[2] = 50000,
ppd[3] = 60000,
ppd[4] = 60000,
ppd[5] = 70000,
ppd[6] = 70000,
ppd[7] = 80000,
ppd[8] = 80000,
ppd[9] = 80000,
ppd[10] = 90000,
ppd[11] = 100000,
ppd[12] = 100000,
ppd[13] = 100000,
ppd[14] = 150000
]]
function bindt()
    sampAddChatMessage('hiiiiii', color)
end
        imgui.PushItemWidth(150)
    imgui.Combo(u8'Фракция',combobombo1,checkfrac,#checkfrac)
if combobombo1.v == 5 then
imgui.SameLine()
    imgui.SetCursorPosX(242)
imgui.Combo(u8'Ранг',combobombo,pfbi,#pfbi)
elseif combobombo1.v == 3 then
    imgui.SameLine()
        imgui.SetCursorPosX(242)
    imgui.Combo(u8'Ранг',combobombo,pmed,#pmed)
elseif combobombo1.v == 4 then
    imgui.SameLine()
        imgui.SetCursorPosX(242)
    imgui.Combo(u8'Ранг',combobombo,parmy,#parmy)
elseif combobombo1.v == 2 then
    imgui.SameLine()

        imgui.SetCursorPosX(242)
    imgui.Combo(u8'Ранг',combobombo,ppd,#ppd)
elseif combobombo1.v == 1 then
    imgui.SameLine()
        imgui.SetCursorPosX(242)
    imgui.Combo(u8'Ранг',combobombo,pmayor,#pmayor)

elseif combobombo1.v == 6 then
    imgui.SameLine()
    imgui.SetCursorPosX(242)
    imgui.Combo(u8'Ранг',combobombo,pds,#pds)
elseif combobombo1.v == 7 then
    imgui.SameLine()
    imgui.SetCursorPosX(242)
    imgui.Combo(u8'Ранг',combobombo,pnews,#pnews)

end


        imgui.PushItemWidth(150)
if     imgui.InputText(u8'1 требование', buffer1) then
        mainIni.trebovania.treb1 = buffer1.v
        inicfg.save(mainIni, 'px.ini')
    end
    imgui.SameLine()
    if imgui.Button(u8'Очистить 1 требование') then
        mainIni.trebovania.treb1 = ' '
        buffer1.v = ' '
        inicfg.save(mainIni,'px.ini')
    end

        imgui.SameLine()
        imgui.SetCursorPosX(387)
    if    imgui.SliderInt(u8'Повязка (Клист)',cbuffer,1,33) then
        mainIni.trebovania.tclist = cbuffer.v
        inicfg.save(mainIni,'px.ini')
    end
if        imgui.InputText(u8'2 требование', buffer2) then
         mainIni.trebovania.treb2 = buffer2.v
        inicfg.save(mainIni, 'px.ini')
    end
        imgui.SameLine()
        if imgui.Button(u8'Очистить 2 требование') then
            mainIni.trebovania.treb2 = ' '
                    buffer2.v = ''
            inicfg.save(mainIni,'px.ini')
        end
        imgui.SameLine()
        imgui.InputText(u8'РП отыгровки по приезду',priezd)
        if priezd.v:find('/me (.+)') then
    local text = priezd.v:match('/me (.+)')
    priezd.v = text
        end
        imgui.SameLine()
        imgui.TextQuestion(u8('Вводите без /me'))
        if imgui.InputText(u8'3 требование', buffer3) then
        mainIni.trebovania.treb3 = buffer3.v
        inicfg.save(mainIni, 'px.ini')
    end
    imgui.SameLine()
    if imgui.Button(u8'Очистить 3 требование') then
        mainIni.trebovania.treb3 = ' '
                buffer3.v = ' '
        inicfg.save(mainIni,'px.ini')
    end
        imgui.SameLine()
        imgui.InputText(u8'Слова по приезду',priezds)
        if priezds.v:find('/s (.+)') then
    local text = priezds.v:match('/s (.+)')
    priezds.v = text
        end
        imgui.SameLine()
        imgui.TextQuestion(u8('Текст будет прописан через /s'))
        if imgui.InputText(u8'4 требование', buffer4) then
        mainIni.trebovania.treb4 = buffer4.v
        inicfg.save(mainIni, 'px.ini')
    end
    imgui.SameLine()
    if imgui.Button(u8'Очистить 4 требование') then
        mainIni.trebovania.treb4 = ' '
                buffer4.v = ' '
        inicfg.save(mainIni,'px.ini')
    end
        imgui.SameLine()
         imgui.ToggleButton("##1", imBool)

        imgui.SameLine()
        imgui.Text(u8'Включить таймер')


        if imgui.InputText(u8'5 требование', buffer5) then
        mainIni.trebovania.treb5 = buffer5.v
        inicfg.save(mainIni, 'px.ini')
    end
        imgui.SameLine()
        if imgui.Button(u8'Очистить 5 требование') then
            mainIni.trebovania.treb5 = ' '
                    buffer5.v = ' '
            inicfg.save(mainIni,'px.ini')
        end
        imgui.SameLine()
        if imBool.v == true then
imgui.SliderInt(u8"Таймер (минуты : секунды)", min, 10--[[минимальное число]], 20--[[максимальное число]])
imgui.PopItemWidth()
imgui.SetCursorPosX(387)
if imgui.Button(u8'Начать отсчёт') then
        if timer < os.time() then -- если таймер не идёт (меньше, чем время на пк)
                timer = os.time() + (min.v * 60) -- время на пк(в секундах) + перевод значения слайдера в минуты
        else -- если таймер больше, чем время на пк (если идёт)
                sampAddChatMessage('Ошибка, отсчёт уже идёт!', -1)
        end
end
if timer >= os.time() then -- пока таймер больше времени на пк (пока он идёт)
        imgui.SameLine()
    --    timeost = math.floor((timer - os.time())/60)..':'..math.floor((timer - os.time())%60)
        imgui.Text(math.floor((timer - os.time())/60)..':'..math.floor((timer - os.time())%60))

        --math.floor для того, чтобы после деления выводило целое число
        --(timer - os.time())/60) -- ((таймер-время на пк/)1 минуту) для определения минут
        --(timer - os.time())%60) -- остаток деления на 60 (секунды)
    end
end
imgui.SetCursorPosX(5)
imgui.SetCursorPosY(155)
        if imgui.Button(u8'Очистить все требования ') then
            mainIni.trebovania.treb1 = ' '
                mainIni.trebovania.treb2 = ' '
                    mainIni.trebovania.treb3 = ' '
                        mainIni.trebovania.treb4 = ' '
                            mainIni.trebovania.treb5 = ' '
                            buffer1.v = ''
                            buffer2.v = ''
                            buffer3.v = ''
                            buffer4.v = ''
                            buffer5.v = ''
            inicfg.save(mainIni,'px.ini')
        end



imgui.EndChild()
-- ===================================================================================================================================================================================================================================================================
        imgui.BeginChild("##secondchild", imgui.ImVec2(715, 130), true)
        if imgui.Button(u8'Показать все требования') then
    if mainIni.trebovania.treb1 == '' and mainIni.trebovania.treb2 == '' and mainIni.trebovania.treb3 == '' and mainIni.trebovania.treb4 == '' and mainIni.trebovania.treb5 == '' or mainIni.trebovania.treb1 == ' ' and mainIni.trebovania.treb2 == ' ' and mainIni.trebovania.treb3 == ' ' and mainIni.trebovania.treb4 == ' ' and mainIni.trebovania.treb5 == ' ' then
                sampAddChatMessage(tag .. '{FFFFFF}Нет требовании, введите их в поля требовании.', color)
        else
                --    sampAddChatMessage(tag..(u8:decode(buffer1.v)).. ' ' .. (u8:decode(buffer2.v)) .. ' ' .. (u8:decode(buffer3.v)) ..' ' .. (u8:decode(buffer4.v)) .. ' ' .. (u8:decode(buffer5.v)), red_color)
                ftext(mainIni.trebovania.treb1 .. ' ' .. mainIni.trebovania.treb2 .. ' ' .. mainIni.trebovania.treb3 .. ' ' .. mainIni.trebovania.treb4 .. ' ' .. mainIni.trebovania.treb5)
            end
end
        imgui.SameLine()
        if imgui.HotKey('##3', ActiveClockMenu2, tLastKeys, 100) then
            rkeys.changeHotKey(bindst, ActiveClockMenu2.v)
            sampAddChatMessage(tag..'{F4A460}Старая горячая клавиша: {FFFFFF}'.. table.concat(rkeys.getKeysName(tLastKeys.v),'+').. '{F4A460} Новая горячая клавиша {FFFFFF}'.. table.concat(rkeys.getKeysName(ActiveClockMenu2.v), " + "), color)
            mainIni.hotkey.bindst = encodeJson(ActiveClockMenu2.v)
            inicfg.save(mainIni, 'px.ini')
        end
        imgui.SameLine()
        imgui.TextQuestion(u8('Чтобы показать все требования заполните все поля требовании'))
        imgui.SameLine()
        imgui.SetCursorPosX(355)
        if imgui.Button(u8('Отыграть в чат')) then
            if priezd.v == '' then
                sampAddChatMessage(tag.. '{ff0040}Ошибка! {FFFFFF}Вы не ввели отыгровку', color)
            else
            sampSendChat('/me ' .. (u8:decode(priezd.v)))
        end
    end
        if imgui.Button(u8'Сказать все требования в рацию') then
            if buffer1.v == '' and buffer2.v == '' and buffer3.v == '' and buffer4.v == '' and buffer5.v == '' then
                                    sampAddChatMessage(tag .. '{FFFFFF}Нет требовании, введите их в поля требовании.', color)
                                else
        sampSendChat('/r ' .. (u8:decode(buffer1.v)).. ' ' .. (u8:decode(buffer2.v)) .. ' ' .. (u8:decode(buffer3.v)) ..' ' .. (u8:decode(buffer4.v)) .. ' ' .. (u8:decode(buffer5.v)))
        end
    end
        imgui.SameLine()
        function clockfunc()
                    sampSendChat('/r ' .. (u8:decode(buffer1.v)).. ' ' .. (u8:decode(buffer2.v)) .. ' ' .. (u8:decode(buffer3.v)) ..' ' .. (u8:decode(buffer4.v)) .. ' ' .. (u8:decode(buffer5.v)))
        end
        if imgui.HotKey('##1', ActiveClockMenu, tLastKeys, 100) then
            rkeys.changeHotKey(bindr, ActiveClockMenu.v)
            sampAddChatMessage(tag..'{F4A460}Старая горячая клавиша: {FFFFFF}'.. table.concat(rkeys.getKeysName(tLastKeys.v),'+').. '{F4A460} Новая горячая клавиша: {FFFFFF}'.. table.concat(rkeys.getKeysName(ActiveClockMenu.v), " + "), color)
            mainIni.hotkey.bindr = encodeJson(ActiveClockMenu.v)
            inicfg.save(mainIni, 'px.ini')
        end
        imgui.SameLine()
        imgui.TextQuestion(u8('Чтобы сказать требования в рацию заполните все поля требовании'))
        imgui.SameLine()
        imgui.SetCursorPosX(355)
        if imgui.Button(u8('Крикнуть по приезду')) then
            if priezds.v == '' then
                sampAddChatMessage(tag .. '{FFFFFF}Нечего кричать,введите текст в поле.', color)
            else
            sampSendChat('/s ' .. priezds.v)
        end
    end

        if imgui.Button(u8'Сказать все требования в рацию /rb ') then
            if buffer1.v == '' and buffer2.v == '' and buffer3.v == '' and buffer4.v == '' and buffer5.v == '' then
                                    sampAddChatMessage(tag .. '{FFFFFF}Нет требовании, введите их в поля требовании.', color)
                                else
        sampSendChat('/rb ' .. (u8:decode(buffer1.v)).. ' ' .. (u8:decode(buffer2.v)) .. ' ' .. (u8:decode(buffer3.v)) ..' ' .. (u8:decode(buffer4.v)) .. ' ' .. (u8:decode(buffer5.v)))
        end
    end
        imgui.SameLine()
        if imgui.HotKey('##2', ActiveClockMenu1, tLastKeys, 100) then
            rkeys.changeHotKey(bindrb, ActiveClockMenu1.v)
            sampAddChatMessage(tag..'{F4A460}Старая горячая клавиша: {FFFFFF}'.. table.concat(rkeys.getKeysName(tLastKeys.v),'+').. '{F4A460} Новая горячая клавиша {FFFFFF}'.. table.concat(rkeys.getKeysName(ActiveClockMenu1.v), " + "), color)
            mainIni.hotkey.bindrb = encodeJson(ActiveClockMenu1.v)
            inicfg.save(mainIni, 'px.ini')
        end
        imgui.SameLine()
        imgui.TextQuestion(u8('Чтобы сказать требования в рацию заполните все поля требовании'))
        imgui.SameLine()
        imgui.Button(u8'Показать оставшееся время')
        imgui.SameLine()
        if imgui.HotKey('##4', ActiveClockMenu3, tLastKeys, 100) then
            rkeys.changeHotKey(bindt, ActiveClockMenu3.v)
            sampAddChatMessage(tag..'{F4A460}Старая горячая клавиша: {FFFFFF}'.. table.concat(rkeys.getKeysName(tLastKeys.v),'+').. '{F4A460} Новая горячая клавиша {FFFFFF}'.. table.concat(rkeys.getKeysName(ActiveClockMenu3.v), " + "), color)
            mainIni.hotkey.bindt = encodeJson(ActiveClockMenu3.v)
            inicfg.save(mainIni, 'px.ini')
        end
        if imgui.Button(u8'Надеть повязку (Клист)') then
            if cbuffer.v == 0 then
                sampAddChatMessage(tag .. '{FFFFFF}Вы пытаетесь включить {FF0040}нулевой клист. {FFFFFF} Для начала оденьте маску или выберите другой клист', color)
            end
            sampSendChat('/clist ' .. cbuffer.v)
        end

        if imgui.Button(u8'Красная тема') then
            themes.SwitchColorTheme(2)
            mainIni.itheme.theme = 2
            inicfg.save(mainIni, 'px.ini')
        end
        imgui.SameLine()
        if imgui.Button(u8'Черная тема') then
            themes.SwitchColorTheme(5)
            mainIni.itheme.theme = 5
            inicfg.save(mainIni, 'px.ini')
        end
        imgui.SameLine()
        if imgui.Button(u8'Фиолетовая тема') then
            themes.SwitchColorTheme(6)
            mainIni.itheme.theme = 6
            inicfg.save(mainIni, 'px.ini')
        end
        imgui.SameLine()
        if imgui.Button(u8'Синяя тема') then
            themes.SwitchColorTheme()
            mainIni.itheme.theme = 0
            inicfg.save(mainIni, 'px.ini')
        end

imgui.EndChild()
        imgui.End()
    end
    if extra_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(200,180),imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw/2),sh/2),imgui.Cond.FirstUseEver, imgui.ImVec2(0.5,0.5))
        imgui.Begin(u8"Хелпер Похиток", extra_window_state,imgui.WindowFlags.NoResize)
        imgui.SetCursorPosX(40)
        imgui.SetCursorPosY(30)
        if     imgui.Button(u8'Для агентов',  imgui.ImVec2(120, 20)) then
             agent_window_state.v = not agent_window_state.v
        end
        imgui.SetCursorPosX(40)
        imgui.SetCursorPosY(55)
        function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
end
apply_custom_style()
if     imgui.Button(u8'Для операторов HRT', (imgui.ImVec2(133,20))) then
     poxititel_window_state.v = not poxititel_window_state.v
end
apply_custom_style()
imgui.SetCursorPosX(30)
imgui.SetCursorPosY(80)
if imgui.CollapsingHeader(u8'Действия со скриптом') then
    imgui.SetCursorPosX(30)
    imgui.SetCursorPosY(130)
if imgui.Button(u8('Перезагрузить скрипт'),(imgui.ImVec2(133,20))) then
sampAddChatMessage(tag .. '{FFFFFF}Скрипт перезагружен.', color)
thisScript():reload()
end
imgui.SetCursorPosX(30)
imgui.SetCursorPosY(105)
if imgui.Button(u8('Выключить скрипт'),(imgui.ImVec2(133,20))) then
    sampAddChatMessage(tag .. '{FFFFFF}Выгружаю скрипт...', color)
    thisScript():unload()
end
end
            imgui.End()
            end
end
end
end
 
  • Нравится
Реакции: shizzard