Не работает lua скрипт

shawtyglock.

Активный
Автор темы
188
63
Пишу скрипт, но что-то сломалось, как пофиксить не могу понять (не бейте, только начинаю), ошибка в консоли:
(error) Shawty Helper: ...\EVIL 17K GTA Original\moonloader\Shawty Helper Menu.lua:46: sol: no matching function call takes this number of arguments and the specified types
stack traceback:
[C]: in function 'ImInt'
...\EVIL 17K GTA Original\moonloader\Shawty Helper Menu.lua:46: in main chunk
[ML] (error) Shawty Helper: Script died due to an error. (10807FAC)

Код:

Lua:
script_name('Shawty Helper')
script_author('shawtyglock')

require "lib.moonloader"
local imgui = require 'imgui'
local sampev = require 'lib.samp.events'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local main_window_state = imgui.ImBool(false)
local rkeys = require 'rkeys'
imgui.HotKey = require('imgui_addons').HotKey

local fa = require 'faIcons'
local fonts = renderCreateFont("Arial", 9, 5)

local tLastKeys = {}

local themes = import "resource/imgui_themes.lua"

local cheked_radio = imgui.ImInt(1)

local path = getGameDirectory()..'\\moonloader\\config\\shelper.json'

local config = {
    armour = {v = {VK_C}},
    mask = {v = {VK_V}},
    drugs = {v = {VK_X}},
    FontSize = 9,
    FlagFont = 5,
    Bell = false,
    Kill = false,
    Stats = false,
    HPHud = false,
    CPX = 13,
    CPY = 992
}

local font = renderCreateFont("Arial", config.SizeFont, config.FlagFont)

--ImGui
local checkkill = imgui.ImBool(config.Kill)
local checkstats = imgui.ImBool(config.Stats)
local checkhphud = imgui.ImBool(config.HPHud)
local checkbell = imgui.ImBool(config.Bell)
local sizefont = imgui.ImInt(config.SizeFont)
local flagfont = imgui.ImInt(config.FlagFont)

-- Checkbox
local choose_Kill = imgui.ImBool(false)
local choose_Stats = imgui.ImBool(false)
local choose_HPHud = imgui.ImBool(false)
local choose_Bell = imgui.ImBool(false)

function theme()
    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(0.95, 0.96, 0.98, 1.00);
    colors[clr.TextDisabled]           = ImVec4(0.29, 0.29, 0.29, 1.00);
    colors[clr.WindowBg]               = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.ChildWindowBg]          = ImVec4(0.12, 0.12, 0.12, 1.00);
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94);
    colors[clr.Border]                 = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.BorderShadow]           = ImVec4(1.00, 1.00, 1.00, 0.10);
    colors[clr.FrameBg]                = ImVec4(0.22, 0.22, 0.22, 1.00);
    colors[clr.FrameBgHovered]         = ImVec4(0.18, 0.18, 0.18, 1.00);
    colors[clr.FrameBgActive]          = ImVec4(0.09, 0.12, 0.14, 1.00);
    colors[clr.TitleBg]                = ImVec4(0.14, 0.14, 0.14, 0.81);
    colors[clr.TitleBgActive]          = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51);
    colors[clr.MenuBarBg]              = ImVec4(0.20, 0.20, 0.20, 1.00);
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.39);
    colors[clr.ScrollbarGrab]          = ImVec4(0.36, 0.36, 0.36, 1.00);
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.18, 0.22, 0.25, 1.00);
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.ComboBg]                = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.CheckMark]              = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrab]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrabActive]       = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.Button]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ButtonHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ButtonActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.Header]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.HeaderHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.HeaderActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.ResizeGrip]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ResizeGripHovered]      = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ResizeGripActive]       = ImVec4(1.00, 0.19, 0.19, 1.00);
    colors[clr.CloseButton]            = ImVec4(0.40, 0.39, 0.38, 0.16);
    colors[clr.CloseButtonHovered]     = ImVec4(0.40, 0.39, 0.38, 0.39);
    colors[clr.CloseButtonActive]      = ImVec4(0.40, 0.39, 0.38, 1.00);
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00);
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00);
    colors[clr.PlotHistogram]          = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.18, 0.18, 1.00);
    colors[clr.TextSelectedBg]         = ImVec4(1.00, 0.32, 0.32, 1.00);
    colors[clr.ModalWindowDarkening]   = ImVec4(0.26, 0.26, 0.26, 0.60);
end
theme()

local menu = 1
local fa_font = nil
local fontsize = nil

-- KillState
local kills = 0
local deaths = 0
local ratio = 0
local dead_players = {}
local current = 0
local total = 0

-- Load json
if not doesFileExist(path) then
    local f = io.open(path, 'w+')
    f:write(encodeJson(config)):close()
else
    local f = io.open(path, "r")
    a = f:read("*a")
    config = decodeJson(a)
    f:close()
end

function imgui.TextQuestion(text)
    imgui.SameLine()
    imgui.TextDisabled("(?)")
    if imgui.IsItemHovered() then
        imgui.BeginTooltip()
        imgui.TextUnformatted(u8(text))
        imgui.EndTooltip()
    end
end

function imgui.CenterTextColoredRGB(text)
    local width = imgui.GetWindowWidth()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local ImVec4 = imgui.ImVec4

    local explode_argb = function(argb)
        local a = bit.band(bit.rshift(argb, 24), 0xFF)
        local r = bit.band(bit.rshift(argb, 16), 0xFF)
        local g = bit.band(bit.rshift(argb, 8), 0xFF)
        local b = bit.band(argb, 0xFF)
        return a, r, g, b
    end

    local getcolor = function(color)
        if color:sub(1, 6):upper() == 'SSSSSS' then
            local r, g, b = colors[1].x, colors[1].y, colors[1].z
            local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
            return ImVec4(r, g, b, a / 255)
        end
        local color = type(color) == 'string' and tonumber(color, 16) or color
        if type(color) ~= 'number' then return end
        local r, g, b, a = explode_argb(color)
        return imgui.ImColor(r, g, b, a):GetVec4()
    end

    local render_text = function(text_)
        for w in text_:gmatch('[^\r\n]+') do
            local textsize = w:gsub('{.-}', '')
            local text_width = imgui.CalcTextSize(u8(textsize))
            imgui.SetCursorPosX( width / 2 - text_width .x / 2 )
            local text, colors_, m = {}, {}, 1
            w = w:gsub('{(......)}', '{%1FF}')
            while w:find('{........}') do
                local n, k = w:find('{........}')
                local color = getcolor(w:sub(n + 1, k - 1))
                if color then
                    text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
                    colors_[#colors_ + 1] = color
                    m = n
                end
                w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
            end
            if text[0] then
                for i = 0, #text do
                    imgui.TextColored(colors_[i] or colors[1], u8(text[i]))
                    imgui.SameLine(nil, 0)
                end
                imgui.NewLine()
            else
                imgui.Text(u8(w))
            end
        end
    end
    render_text(text)
end

function main()
    if not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("{FF0000}[Shawty Helper]{FFFFFF} Скрипт успешно запущен! Активация: {FF0000}/sh.", -1)
    sampRegisterChatCommand("sh", function() main_window_state.v = not main_window_state.v end)

        bind = rkeys.registerHotKey(config.armour.v, true, function()
        sampSendChat("/armour")
    end)

        bind = rkeys.registerHotKey(config.mask.v, true, function()
        sampSendChat("/mask")
    end)

        bind = rkeys.registerHotKey(config.drugs.v, true, function()
            hp = getCharHealth(PLAYER_PED)
            if hp < 120 then
                    sampSendChat('/usedrugs 3')
            elseif hp >= 120 and hp < 140 then
                    sampSendChat('/usedrugs 2')
            elseif hp >= 140 then
                    sampSendChat('/usedrugs 1')
            end
    end)

    while true do
        wait(0)
        imgui.Process = main_window_state.v
    end
end

local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
function imgui.BeforeDrawFrame()
    if fa_font == nil then
        local font_config = imgui.ImFontConfig()
        font_config.MergeMode = true
        fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fontawesome-webfont.ttf', 14.0, font_config, fa_glyph_ranges)
    end
end

function sampev.onSendGiveDamage(playerId,damage)
    if config.Stats then
        dmg = tonumber(damage)
        dmg = math.floor(dmg)
        total = total + dmg -- Total Damage
        current = current + dmg -- Current Damage
        local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        result, handle2 = sampGetCharHandleBySampPlayerId(playerId)
        health = sampGetPlayerHealth(playerId)
        if health < damage or health == 0 then
                kills = kills + 1
    end
    if config.Kill then
        health = sampGetPlayerHealth(playerId)
        if health < damage or health == 0 then
            printStyledString('-bezdar', 5000, 7)
        end
    end
    end
end

function sampev.onSendSpawn()
    lua_thread.create(function()
        killss = 0
        if config.Stats then
            if firstspawn == false then wait(30) firstspawn = true end
            if firstspawn == true then
                deaths = deaths + 1
            end
        end
        local TimeLeft = math.floor(Timer.start + TimerTime - os.clock())
    end)
end

math.round = function(num, idp)
    local mult = 10^(idp or 0)
    return math.floor(num * mult + 0.5) / mult
end

function statsupdate()
    while true do wait(0)
        if config.Stats then
            renderFontDrawText(font,"{ffffff}Kills: {ef3226}"..kills.."\n{ffffff}Deaths: {ef3226}"..deaths.."\n{ffffff}Damage: {ef3226}"..total, config.CPX, config.CPY,0xffffffff)
        end
    end
end

function hphud()
    while true do wait(0)
        if config.HPHud then
            if not sampTextdrawIsExists(500) and sampIsLocalPlayerSpawned() then
                sampTextdrawCreate(500, "_", 569, 66.9)
            end
            sampTextdrawSetLetterSizeAndColor(500, 0.29, 0.9, 4294967295.0)
            sampTextdrawSetPos(500, 569.2, 66.9)
            sampTextdrawSetStyle(500, 3)
            sampTextdrawSetAlign(500, 569)
            sampTextdrawSetOutlineColor(500, 1, 4278190080.0)
            sampTextdrawSetString(500, "" .. getCharHealth(PLAYER_PED))
        elseif not config.HPHud then
            sampTextdrawDelete(500)
        end
    end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(750, 400), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Shawty Helper", main_window_state, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize)
                imgui.BeginChild('##left', imgui.ImVec2(250, 400), true, imgui.WindowFlags.NoScrollbar + imgui.WindowFlags.NoScrollWithMouse)
             if imgui.Button(u8('Информация'), imgui.ImVec2(-1, 50)) then
                     menu = 1
             end
             if imgui.Button(u8('Функции'), imgui.ImVec2(-1, 50)) then
                     menu = 2
             end
             if imgui.Button(u8('Бинды'), imgui.ImVec2(-1, 50)) then
                     menu = 3
             end
             if imgui.Button(u8('Настройки'), imgui.ImVec2(-1, 50)) then
                     menu = 4
             end
             imgui.EndChild()
             imgui.SameLine()
             imgui.BeginChild('##right', imgui.ImVec2(500, 400), true, imgui.WindowFlags.NoScrollbar + imgui.WindowFlags.NoScrollWithMouse)
             if menu == 1 then
                 imgui.CenterTextColoredRGB('{FFFFFF}Спасибо за пользование Shawty Helper\n{FFFFFF}Автор данного скрипта - shawtyglock\n{FFFFFF}Скрипт находится в процессе разработки\n{FFFFFF}Если желаете добавить что-нибудь в скрипт по тематике\n{FFFFFF}или нашли ошибки в скрипте - пишите мне в Discord: FluffyBeast#8186')
             end
             if menu == 2 then
               imgui.Checkbox("KillState", choose_Kill)
                 if choose_Kill.v then
                     config.Kill = checkkill.v
                     JSONSave()
                 end

                 imgui.Checkbox("CaptStats", choose_Stats)
                 if choose_Stats.v then
                     config.Stats = checkstats.v
                     JSONSave()
                 end

                 imgui.Checkbox("HPHud", choose_HPHud)
                 if choose_HPHud.v then
                     config.HPHud = checkhphud.v
                     JSONSave()
                 end

                 imgui.Checkbox("Kolokol", choose_Bell)
                 if choose_Bell.v then
                     config.Bell = checkbell.v
                     JSONSave()
                 end
             end

             if menu == 3 then
                 if imgui.HotKey("##1", config.armour, tLastKeys, 50) then
                            rkeys.changeHotKey(bind, config.armour.v)
                            JSONSave()
                 end

                 imgui.SameLine()
                 imgui.Text(u8"Использование армора")
                 imgui.TextQuestion("Использует армор на указанную вами клавишу/комбинацию клавиш")

                 if imgui.HotKey("##2", config.mask, tLastKeys, 50) then
                            rkeys.changeHotKey(bind, config.mask.v)
                            JSONSave()
                 end

                 imgui.SameLine()
                 imgui.Text(u8"Использование маски")
                 imgui.TextQuestion("Использует маску на указанную вами клавишу/комбинацию клавиш.")

                 if imgui.HotKey("##3", config.drugs, tLastKeys, 50) then
                         rkeys.changeHotKey(bind, config.drugs.v)
                         JSONSave()
                 end

                 imgui.SameLine()
                 imgui.Text(u8"Использование наркотиков")
                    imgui.TextQuestion("Использует наркотики в зависимости от количества вашего хп на указанную вами клавишу/комбинацию клавиш.")
             end
             if menu == 4 then
                 imgui.CenterTextColoredRGB('{FFFFFF} Находится в процессе разработки')
             end
             imgui.EndChild()
             imgui.End()
    end
end

function JSONSave()
    if doesFileExist(path) then
        local f = io.open(path, 'w+')
        if f then
            f:write(encodeJson(config)):close()
        end
    end
end
 

XRLM

Против ветра рождённый
Проверенный
1,503
1,062
Пишу скрипт, но что-то сломалось, как пофиксить не могу понять (не бейте, только начинаю), ошибка в консоли:
(error) Shawty Helper: ...\EVIL 17K GTA Original\moonloader\Shawty Helper Menu.lua:46: sol: no matching function call takes this number of arguments and the specified types
stack traceback:
[C]: in function 'ImInt'
...\EVIL 17K GTA Original\moonloader\Shawty Helper Menu.lua:46: in main chunk
[ML] (error) Shawty Helper: Script died due to an error. (10807FAC)

Код:

Lua:
script_name('Shawty Helper')
script_author('shawtyglock')

require "lib.moonloader"
local imgui = require 'imgui'
local sampev = require 'lib.samp.events'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local main_window_state = imgui.ImBool(false)
local rkeys = require 'rkeys'
imgui.HotKey = require('imgui_addons').HotKey

local fa = require 'faIcons'
local fonts = renderCreateFont("Arial", 9, 5)

local tLastKeys = {}

local themes = import "resource/imgui_themes.lua"

local cheked_radio = imgui.ImInt(1)

local path = getGameDirectory()..'\\moonloader\\config\\shelper.json'

local config = {
    armour = {v = {VK_C}},
    mask = {v = {VK_V}},
    drugs = {v = {VK_X}},
    FontSize = 9,
    FlagFont = 5,
    Bell = false,
    Kill = false,
    Stats = false,
    HPHud = false,
    CPX = 13,
    CPY = 992
}

local font = renderCreateFont("Arial", config.SizeFont, config.FlagFont)

--ImGui
local checkkill = imgui.ImBool(config.Kill)
local checkstats = imgui.ImBool(config.Stats)
local checkhphud = imgui.ImBool(config.HPHud)
local checkbell = imgui.ImBool(config.Bell)
local sizefont = imgui.ImInt(config.SizeFont)
local flagfont = imgui.ImInt(config.FlagFont)

-- Checkbox
local choose_Kill = imgui.ImBool(false)
local choose_Stats = imgui.ImBool(false)
local choose_HPHud = imgui.ImBool(false)
local choose_Bell = imgui.ImBool(false)

function theme()
    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(0.95, 0.96, 0.98, 1.00);
    colors[clr.TextDisabled]           = ImVec4(0.29, 0.29, 0.29, 1.00);
    colors[clr.WindowBg]               = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.ChildWindowBg]          = ImVec4(0.12, 0.12, 0.12, 1.00);
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94);
    colors[clr.Border]                 = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.BorderShadow]           = ImVec4(1.00, 1.00, 1.00, 0.10);
    colors[clr.FrameBg]                = ImVec4(0.22, 0.22, 0.22, 1.00);
    colors[clr.FrameBgHovered]         = ImVec4(0.18, 0.18, 0.18, 1.00);
    colors[clr.FrameBgActive]          = ImVec4(0.09, 0.12, 0.14, 1.00);
    colors[clr.TitleBg]                = ImVec4(0.14, 0.14, 0.14, 0.81);
    colors[clr.TitleBgActive]          = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51);
    colors[clr.MenuBarBg]              = ImVec4(0.20, 0.20, 0.20, 1.00);
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.39);
    colors[clr.ScrollbarGrab]          = ImVec4(0.36, 0.36, 0.36, 1.00);
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.18, 0.22, 0.25, 1.00);
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.ComboBg]                = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.CheckMark]              = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrab]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrabActive]       = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.Button]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ButtonHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ButtonActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.Header]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.HeaderHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.HeaderActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.ResizeGrip]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ResizeGripHovered]      = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ResizeGripActive]       = ImVec4(1.00, 0.19, 0.19, 1.00);
    colors[clr.CloseButton]            = ImVec4(0.40, 0.39, 0.38, 0.16);
    colors[clr.CloseButtonHovered]     = ImVec4(0.40, 0.39, 0.38, 0.39);
    colors[clr.CloseButtonActive]      = ImVec4(0.40, 0.39, 0.38, 1.00);
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00);
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00);
    colors[clr.PlotHistogram]          = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.18, 0.18, 1.00);
    colors[clr.TextSelectedBg]         = ImVec4(1.00, 0.32, 0.32, 1.00);
    colors[clr.ModalWindowDarkening]   = ImVec4(0.26, 0.26, 0.26, 0.60);
end
theme()

local menu = 1
local fa_font = nil
local fontsize = nil

-- KillState
local kills = 0
local deaths = 0
local ratio = 0
local dead_players = {}
local current = 0
local total = 0

-- Load json
if not doesFileExist(path) then
    local f = io.open(path, 'w+')
    f:write(encodeJson(config)):close()
else
    local f = io.open(path, "r")
    a = f:read("*a")
    config = decodeJson(a)
    f:close()
end

function imgui.TextQuestion(text)
    imgui.SameLine()
    imgui.TextDisabled("(?)")
    if imgui.IsItemHovered() then
        imgui.BeginTooltip()
        imgui.TextUnformatted(u8(text))
        imgui.EndTooltip()
    end
end

function imgui.CenterTextColoredRGB(text)
    local width = imgui.GetWindowWidth()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local ImVec4 = imgui.ImVec4

    local explode_argb = function(argb)
        local a = bit.band(bit.rshift(argb, 24), 0xFF)
        local r = bit.band(bit.rshift(argb, 16), 0xFF)
        local g = bit.band(bit.rshift(argb, 8), 0xFF)
        local b = bit.band(argb, 0xFF)
        return a, r, g, b
    end

    local getcolor = function(color)
        if color:sub(1, 6):upper() == 'SSSSSS' then
            local r, g, b = colors[1].x, colors[1].y, colors[1].z
            local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
            return ImVec4(r, g, b, a / 255)
        end
        local color = type(color) == 'string' and tonumber(color, 16) or color
        if type(color) ~= 'number' then return end
        local r, g, b, a = explode_argb(color)
        return imgui.ImColor(r, g, b, a):GetVec4()
    end

    local render_text = function(text_)
        for w in text_:gmatch('[^\r\n]+') do
            local textsize = w:gsub('{.-}', '')
            local text_width = imgui.CalcTextSize(u8(textsize))
            imgui.SetCursorPosX( width / 2 - text_width .x / 2 )
            local text, colors_, m = {}, {}, 1
            w = w:gsub('{(......)}', '{%1FF}')
            while w:find('{........}') do
                local n, k = w:find('{........}')
                local color = getcolor(w:sub(n + 1, k - 1))
                if color then
                    text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
                    colors_[#colors_ + 1] = color
                    m = n
                end
                w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
            end
            if text[0] then
                for i = 0, #text do
                    imgui.TextColored(colors_[i] or colors[1], u8(text[i]))
                    imgui.SameLine(nil, 0)
                end
                imgui.NewLine()
            else
                imgui.Text(u8(w))
            end
        end
    end
    render_text(text)
end

function main()
    if not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage("{FF0000}[Shawty Helper]{FFFFFF} Скрипт успешно запущен! Активация: {FF0000}/sh.", -1)
    sampRegisterChatCommand("sh", function() main_window_state.v = not main_window_state.v end)

        bind = rkeys.registerHotKey(config.armour.v, true, function()
        sampSendChat("/armour")
    end)

        bind = rkeys.registerHotKey(config.mask.v, true, function()
        sampSendChat("/mask")
    end)

        bind = rkeys.registerHotKey(config.drugs.v, true, function()
            hp = getCharHealth(PLAYER_PED)
            if hp < 120 then
                    sampSendChat('/usedrugs 3')
            elseif hp >= 120 and hp < 140 then
                    sampSendChat('/usedrugs 2')
            elseif hp >= 140 then
                    sampSendChat('/usedrugs 1')
            end
    end)

    while true do
        wait(0)
        imgui.Process = main_window_state.v
    end
end

local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
function imgui.BeforeDrawFrame()
    if fa_font == nil then
        local font_config = imgui.ImFontConfig()
        font_config.MergeMode = true
        fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fontawesome-webfont.ttf', 14.0, font_config, fa_glyph_ranges)
    end
end

function sampev.onSendGiveDamage(playerId,damage)
    if config.Stats then
        dmg = tonumber(damage)
        dmg = math.floor(dmg)
        total = total + dmg -- Total Damage
        current = current + dmg -- Current Damage
        local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        result, handle2 = sampGetCharHandleBySampPlayerId(playerId)
        health = sampGetPlayerHealth(playerId)
        if health < damage or health == 0 then
                kills = kills + 1
    end
    if config.Kill then
        health = sampGetPlayerHealth(playerId)
        if health < damage or health == 0 then
            printStyledString('-bezdar', 5000, 7)
        end
    end
    end
end

function sampev.onSendSpawn()
    lua_thread.create(function()
        killss = 0
        if config.Stats then
            if firstspawn == false then wait(30) firstspawn = true end
            if firstspawn == true then
                deaths = deaths + 1
            end
        end
        local TimeLeft = math.floor(Timer.start + TimerTime - os.clock())
    end)
end

math.round = function(num, idp)
    local mult = 10^(idp or 0)
    return math.floor(num * mult + 0.5) / mult
end

function statsupdate()
    while true do wait(0)
        if config.Stats then
            renderFontDrawText(font,"{ffffff}Kills: {ef3226}"..kills.."\n{ffffff}Deaths: {ef3226}"..deaths.."\n{ffffff}Damage: {ef3226}"..total, config.CPX, config.CPY,0xffffffff)
        end
    end
end

function hphud()
    while true do wait(0)
        if config.HPHud then
            if not sampTextdrawIsExists(500) and sampIsLocalPlayerSpawned() then
                sampTextdrawCreate(500, "_", 569, 66.9)
            end
            sampTextdrawSetLetterSizeAndColor(500, 0.29, 0.9, 4294967295.0)
            sampTextdrawSetPos(500, 569.2, 66.9)
            sampTextdrawSetStyle(500, 3)
            sampTextdrawSetAlign(500, 569)
            sampTextdrawSetOutlineColor(500, 1, 4278190080.0)
            sampTextdrawSetString(500, "" .. getCharHealth(PLAYER_PED))
        elseif not config.HPHud then
            sampTextdrawDelete(500)
        end
    end
end

function imgui.OnDrawFrame()
    if main_window_state.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(750, 400), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Shawty Helper", main_window_state, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize)
                imgui.BeginChild('##left', imgui.ImVec2(250, 400), true, imgui.WindowFlags.NoScrollbar + imgui.WindowFlags.NoScrollWithMouse)
             if imgui.Button(u8('Информация'), imgui.ImVec2(-1, 50)) then
                     menu = 1
             end
             if imgui.Button(u8('Функции'), imgui.ImVec2(-1, 50)) then
                     menu = 2
             end
             if imgui.Button(u8('Бинды'), imgui.ImVec2(-1, 50)) then
                     menu = 3
             end
             if imgui.Button(u8('Настройки'), imgui.ImVec2(-1, 50)) then
                     menu = 4
             end
             imgui.EndChild()
             imgui.SameLine()
             imgui.BeginChild('##right', imgui.ImVec2(500, 400), true, imgui.WindowFlags.NoScrollbar + imgui.WindowFlags.NoScrollWithMouse)
             if menu == 1 then
                 imgui.CenterTextColoredRGB('{FFFFFF}Спасибо за пользование Shawty Helper\n{FFFFFF}Автор данного скрипта - shawtyglock\n{FFFFFF}Скрипт находится в процессе разработки\n{FFFFFF}Если желаете добавить что-нибудь в скрипт по тематике\n{FFFFFF}или нашли ошибки в скрипте - пишите мне в Discord: FluffyBeast#8186')
             end
             if menu == 2 then
               imgui.Checkbox("KillState", choose_Kill)
                 if choose_Kill.v then
                     config.Kill = checkkill.v
                     JSONSave()
                 end

                 imgui.Checkbox("CaptStats", choose_Stats)
                 if choose_Stats.v then
                     config.Stats = checkstats.v
                     JSONSave()
                 end

                 imgui.Checkbox("HPHud", choose_HPHud)
                 if choose_HPHud.v then
                     config.HPHud = checkhphud.v
                     JSONSave()
                 end

                 imgui.Checkbox("Kolokol", choose_Bell)
                 if choose_Bell.v then
                     config.Bell = checkbell.v
                     JSONSave()
                 end
             end

             if menu == 3 then
                 if imgui.HotKey("##1", config.armour, tLastKeys, 50) then
                            rkeys.changeHotKey(bind, config.armour.v)
                            JSONSave()
                 end

                 imgui.SameLine()
                 imgui.Text(u8"Использование армора")
                 imgui.TextQuestion("Использует армор на указанную вами клавишу/комбинацию клавиш")

                 if imgui.HotKey("##2", config.mask, tLastKeys, 50) then
                            rkeys.changeHotKey(bind, config.mask.v)
                            JSONSave()
                 end

                 imgui.SameLine()
                 imgui.Text(u8"Использование маски")
                 imgui.TextQuestion("Использует маску на указанную вами клавишу/комбинацию клавиш.")

                 if imgui.HotKey("##3", config.drugs, tLastKeys, 50) then
                         rkeys.changeHotKey(bind, config.drugs.v)
                         JSONSave()
                 end

                 imgui.SameLine()
                 imgui.Text(u8"Использование наркотиков")
                    imgui.TextQuestion("Использует наркотики в зависимости от количества вашего хп на указанную вами клавишу/комбинацию клавиш.")
             end
             if menu == 4 then
                 imgui.CenterTextColoredRGB('{FFFFFF} Находится в процессе разработки')
             end
             imgui.EndChild()
             imgui.End()
    end
end

function JSONSave()
    if doesFileExist(path) then
        local f = io.open(path, 'w+')
        if f then
            f:write(encodeJson(config)):close()
        end
    end
end
1660058149376.png

in function ImInt - в функции ImInt

по-моему ошибка в 21 строке

советую обратиться сюда https://www.blast.hk/threads/13892/
 
  • Эм
Реакции: DZONE