Вопросы по 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
 
Последнее редактирование:

Сheesecake

Участник
60
2
Идея кода такова, что я пишу /test ID и открывается окно имгуи и в begin должно отобразится ID игрока, который я введу в /test
Желательно, если кто-то знает как можно еще туда вписать ник (по ID который я ввел в /test), подскажите пожалуйста)

Но я не могу понять, как совместить то, что в пишу в /test с окном IMGUI, хелп)

Lua:
require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'
local inicfg = require 'inicfg'
local sampev = require  'lib.samp.events'



-----------------Само окно-------------------------

function imgui.OnDrawFrame()
    if panelone_okno.v then
        imgui.SetNextWindowSize(imgui.ImVec2(440, 60), imgui.Cond.FirstUseEver) -- меняем размер
        imgui.SetNextWindowPos(imgui.ImVec2((sw/2),sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.50, 0.5))
        nick = sampGetPlayerNickname(nick)
        imgui.Begin(u8'Ник: ' ..nick.. ' | ID: '..id..'', panelone_okno, imgui.WindowFlags.NoResize)
        imgui.End()
        end
    end
end

-----Команда----
function cmd_test(pam)
    lua_thread.create(function()
        local id = pam:match('(%d+)')
        if id then
            panelone_okno.v = not panelone_okno.v
            wait(5)
            sampSendChat('/do Тест скрипта. Вы указали ' .. id .. ' ID.')
            wait(3)
            imgui.ShowCursor = false
    else
            sampAddChatMessage('ID', -1)
        end
    end)
end


function sampGetPlayerIdByNickname(nick)
    local _, myid = sampGetPlayerIdByCharHandle(playerPed)
    if tostring(nick) == sampGetPlayerNickname(myid) then return myid end
    for i = 0, sampGetMaxPlayerId() do if sampIsPlayerConnected(i) and sampGetPlayerNickname(i) == tostring(nick) then return i end end
    return -1
end
 

rayprod

Участник
96
1
Как
Lua:
renderFontDrawText
спользовать так, что-бы при скрытом чате или открытом TAB, не показывался текст на экране.?
 

Dmitriy Makarov

25.05.2021
Проверенный
2,481
1,113
Идея кода такова, что я пишу /test ID и открывается окно имгуи и в begin должно отобразится ID игрока, который я введу в /test
Желательно, если кто-то знает как можно еще туда вписать ник (по ID который я ввел в /test), подскажите пожалуйста)

Но я не могу понять, как совместить то, что в пишу в /test с окном IMGUI, хелп)

Lua:
require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'
local inicfg = require 'inicfg'
local sampev = require  'lib.samp.events'



-----------------Само окно-------------------------

function imgui.OnDrawFrame()
    if panelone_okno.v then
        imgui.SetNextWindowSize(imgui.ImVec2(440, 60), imgui.Cond.FirstUseEver) -- меняем размер
        imgui.SetNextWindowPos(imgui.ImVec2((sw/2),sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.50, 0.5))
        nick = sampGetPlayerNickname(nick)
        imgui.Begin(u8'Ник: ' ..nick.. ' | ID: '..id..'', panelone_okno, imgui.WindowFlags.NoResize)
        imgui.End()
        end
    end
end

-----Команда----
function cmd_test(pam)
    lua_thread.create(function()
        local id = pam:match('(%d+)')
        if id then
            panelone_okno.v = not panelone_okno.v
            wait(5)
            sampSendChat('/do Тест скрипта. Вы указали ' .. id .. ' ID.')
            wait(3)
            imgui.ShowCursor = false
    else
            sampAddChatMessage('ID', -1)
        end
    end)
end


function sampGetPlayerIdByNickname(nick)
    local _, myid = sampGetPlayerIdByCharHandle(playerPed)
    if tostring(nick) == sampGetPlayerNickname(myid) then return myid end
    for i = 0, sampGetMaxPlayerId() do if sampIsPlayerConnected(i) and sampGetPlayerNickname(i) == tostring(nick) then return i end end
    return -1
end
Я тут показывал человеку одному как сделать подобное, только с ПКМ + Кнопка. Попробуй под команду переделать под себя.)
 
  • Нравится
Реакции: Сheesecake

Сheesecake

Участник
60
2
Я тут показывал человеку одному как сделать подобное, только с ПКМ + Кнопка. Попробуй под команду переделать под себя.)
Я просто именно не понимаю, как привязать то, что в команде в то, что находится в begin :[
 

Morse

Потрачен
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Как можно сделать проверку если в imgui.InputTextMultiline нету определенного текста то по нажатию на кнопку что бы отправить текст он не отправлялся?
 

moreveal

Известный
Проверенный
859
538
Идея кода такова, что я пишу /test ID и открывается окно имгуи и в begin должно отобразится ID игрока, который я введу в /test
Желательно, если кто-то знает как можно еще туда вписать ник (по ID который я ввел в /test), подскажите пожалуйста)

Но я не могу понять, как совместить то, что в пишу в /test с окном IMGUI, хелп)

Lua:
require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'
local inicfg = require 'inicfg'
local sampev = require  'lib.samp.events'



-----------------Само окно-------------------------

function imgui.OnDrawFrame()
    if panelone_okno.v then
        imgui.SetNextWindowSize(imgui.ImVec2(440, 60), imgui.Cond.FirstUseEver) -- меняем размер
        imgui.SetNextWindowPos(imgui.ImVec2((sw/2),sh/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.50, 0.5))
        nick = sampGetPlayerNickname(nick)
        imgui.Begin(u8'Ник: ' ..nick.. ' | ID: '..id..'', panelone_okno, imgui.WindowFlags.NoResize)
        imgui.End()
        end
    end
end

-----Команда----
function cmd_test(pam)
    lua_thread.create(function()
        local id = pam:match('(%d+)')
        if id then
            panelone_okno.v = not panelone_okno.v
            wait(5)
            sampSendChat('/do Тест скрипта. Вы указали ' .. id .. ' ID.')
            wait(3)
            imgui.ShowCursor = false
    else
            sampAddChatMessage('ID', -1)
        end
    end)
end


function sampGetPlayerIdByNickname(nick)
    local _, myid = sampGetPlayerIdByCharHandle(playerPed)
    if tostring(nick) == sampGetPlayerNickname(myid) then return myid end
    for i = 0, sampGetMaxPlayerId() do if sampIsPlayerConnected(i) and sampGetPlayerNickname(i) == tostring(nick) then return i end end
    return -1
end
Сделай переменную "id" глобальной, убрав 'local'
Код:
id = pam:match('(%d+)')
 
  • Влюблен
Реакции: Сheesecake

Morse

Потрачен
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Как сделать что бы при нажатии на imgui.Button она меняла свой текст внутри неё?
 

Мурпху

Активный
211
39
Сделал такую штуку, начал крашить скрипт(это не весь код)


Lua:
function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    local Colors = style.Colors
    local ImVec4 = imgui.ImVec4
    local ImVec2 = imgui.ImVec2
    style.Alpha = 1
    style.ChildWindowRounding = 15
    style.WindowRounding = 15
    style.GrabRounding = 15
    style.GrabMinSize = 20
    style.FrameRounding = 10
    Colors[imgui.Col.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
    Colors[imgui.Col.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
    Colors[imgui.Col.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
    Colors[imgui.Col.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
    Colors[imgui.Col.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
    Colors[imgui.Col.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
    Colors[imgui.Col.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
    Colors[imgui.Col.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    Colors[imgui.Col.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
    Colors[imgui.Col.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
    Colors[imgui.Col.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    Colors[imgui.Col.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
    Colors[imgui.Col.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
    Colors[imgui.Col.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    Colors[imgui.Col.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    Colors[imgui.Col.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
    Colors[imgui.Col.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    Colors[imgui.Col.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    Colors[imgui.Col.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
    Colors[imgui.Col.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
    Colors[imgui.Col.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
    Colors[imgui.Col.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    Colors[imgui.Col.Button] = ImVec4(0.15, 0.15, 0.18, 1.00)
    Colors[imgui.Col.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
    Colors[imgui.Col.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
    Colors[imgui.Col.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
    Colors[imgui.Col.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    Colors[imgui.Col.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    Colors[imgui.Col.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
    Colors[imgui.Col.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    Colors[imgui.Col.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    Colors[imgui.Col.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
    Colors[imgui.Col.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
    Colors[imgui.Col.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
    Colors[imgui.Col.PlotLines] = ImVec4(0.40, 0.39, 0.38, 0.63)
    Colors[imgui.Col.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
    Colors[imgui.Col.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
    Colors[imgui.Col.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
    Colors[imgui.Col.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
    Colors[imgui.Col.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
end

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

    colors[clr.Text]   = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.TextDisabled]   = ImVec4(0.24, 0.24, 0.24, 1.00)
    colors[clr.WindowBg]              = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.ChildWindowBg]         = ImVec4(0.96, 0.96, 0.96, 1.00)
    colors[clr.PopupBg]               = ImVec4(0.92, 0.92, 0.92, 1.00)
    colors[clr.Border]                = ImVec4(0.86, 0.86, 0.86, 1.00)
    colors[clr.BorderShadow]          = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]               = ImVec4(0.88, 0.88, 0.88, 1.00)
    colors[clr.FrameBgHovered]        = ImVec4(0.82, 0.82, 0.82, 1.00)
    colors[clr.FrameBgActive]         = ImVec4(0.76, 0.76, 0.76, 1.00)
    colors[clr.TitleBg]               = ImVec4(0.00, 0.45, 1.00, 0.82)
    colors[clr.TitleBgCollapsed]      = ImVec4(0.00, 0.45, 1.00, 0.82)
    colors[clr.TitleBgActive]         = ImVec4(0.00, 0.45, 1.00, 0.82)
    colors[clr.MenuBarBg]             = ImVec4(0.00, 0.37, 0.78, 1.00)
    colors[clr.ScrollbarBg]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.ScrollbarGrab]         = ImVec4(0.00, 0.35, 1.00, 0.78)
    colors[clr.ScrollbarGrabHovered]  = ImVec4(0.00, 0.33, 1.00, 0.84)
    colors[clr.ScrollbarGrabActive]   = ImVec4(0.00, 0.31, 1.00, 0.88)
    colors[clr.ComboBg]               = ImVec4(0.92, 0.92, 0.92, 1.00)
    colors[clr.CheckMark]             = ImVec4(0.00, 0.49, 1.00, 0.59)
    colors[clr.SliderGrab]            = ImVec4(0.00, 0.49, 1.00, 0.59)
    colors[clr.SliderGrabActive]      = ImVec4(0.00, 0.39, 1.00, 0.71)
    colors[clr.Button]                = ImVec4(0.00, 0.49, 1.00, 0.59)
    colors[clr.ButtonHovered]         = ImVec4(0.00, 0.49, 1.00, 0.71)
    colors[clr.ButtonActive]          = ImVec4(0.00, 0.49, 1.00, 0.78)
    colors[clr.Header]                = ImVec4(0.00, 0.49, 1.00, 0.78)
    colors[clr.HeaderHovered]         = ImVec4(0.00, 0.49, 1.00, 0.71)
    colors[clr.HeaderActive]          = ImVec4(0.00, 0.49, 1.00, 0.78)
    colors[clr.ResizeGrip]            = ImVec4(0.00, 0.39, 1.00, 0.59)
    colors[clr.ResizeGripHovered]     = ImVec4(0.00, 0.27, 1.00, 0.59)
    colors[clr.ResizeGripActive]      = ImVec4(0.00, 0.25, 1.00, 0.63)
    colors[clr.CloseButton]           = ImVec4(0.00, 0.35, 0.96, 0.71)
    colors[clr.CloseButtonHovered]    = ImVec4(0.00, 0.31, 0.88, 0.69)
    colors[clr.CloseButtonActive]     = ImVec4(0.00, 0.25, 0.88, 0.67)
    colors[clr.PlotLines]             = ImVec4(0.00, 0.39, 1.00, 0.75)
    colors[clr.PlotLinesHovered]      = ImVec4(0.00, 0.39, 1.00, 0.75)
    colors[clr.PlotHistogram]         = ImVec4(0.00, 0.39, 1.00, 0.75)
    colors[clr.PlotHistogramHovered]  = ImVec4(0.00, 0.35, 0.92, 0.78)
    colors[clr.TextSelectedBg]        = ImVec4(0.00, 0.47, 1.00, 0.59)
    colors[clr.ModalWindowDarkening]  = ImVec4(0.20, 0.20, 0.20, 0.35)
end

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

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0

    colors[clr.FrameBg] = ImVec4(0.48, 0.16, 0.16, 0.54)
    colors[clr.FrameBgHovered] = ImVec4(0.98, 0.26, 0.26, 0.40)
    colors[clr.FrameBgActive] = ImVec4(0.98, 0.26, 0.26, 0.67)
    colors[clr.TitleBg] = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive] = ImVec4(0.48, 0.16, 0.16, 1.00)
    colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark] = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.SliderGrab] = ImVec4(0.88, 0.26, 0.24, 1.00)
    colors[clr.SliderGrabActive] = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.Button] = ImVec4(0.98, 0.26, 0.26, 0.40)
    colors[clr.ButtonHovered] = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.ButtonActive] = ImVec4(0.98, 0.06, 0.06, 1.00)
    colors[clr.Header] = ImVec4(0.98, 0.26, 0.26, 0.31)
    colors[clr.HeaderHovered] = ImVec4(0.98, 0.26, 0.26, 0.80)
    colors[clr.HeaderActive] = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.Separator] = colors[clr.Border]
    colors[clr.SeparatorHovered] = ImVec4(0.75, 0.10, 0.10, 0.78)
    colors[clr.SeparatorActive] = ImVec4(0.75, 0.10, 0.10, 1.00)
    colors[clr.ResizeGrip] = ImVec4(0.98, 0.26, 0.26, 0.25)
    colors[clr.ResizeGripHovered] = ImVec4(0.98, 0.26, 0.26, 0.67)
    colors[clr.ResizeGripActive] = ImVec4(0.98, 0.26, 0.26, 0.95)
    colors[clr.TextSelectedBg] = ImVec4(0.98, 0.26, 0.26, 0.35)
    colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled] = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.WindowBg] = ImVec4(0.06, 0.06, 0.06, 0.94)
    colors[clr.ChildWindowBg] = ImVec4(1.00, 1.00, 1.00, 0.00)
    colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.ComboBg] = colors[clr.PopupBg]
    colors[clr.Border] = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg] = ImVec4(0.14, 0.14, 0.14, 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.51, 0.51, 0.51, 1.00)
    colors[clr.CloseButton] = ImVec4(0.41, 0.41, 0.41, 0.50)
    colors[clr.CloseButtonHovered] = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.CloseButtonActive] = ImVec4(0.98, 0.39, 0.36, 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(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening] = ImVec4(0.80, 0.80, 0.80, 0.35)
end


function imgui.OnDrawFrame()
    if GUI.windowState.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(329, 300), imgui.Cond.FirstUseEver)
        imgui.Begin('Fieryfast Software Release Version 1.0', nil, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove)
        imgui.SetCursorPos(imgui.ImVec2(5, 25))
        if imgui.Button('AimBot', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 1
        end
        imgui.SetCursorPos(imgui.ImVec2(57, 25))
        if imgui.Button('Visual', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 2
        end
        imgui.SetCursorPos(imgui.ImVec2(109, 25))
        if imgui.Button('Actor', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 3
        end
        imgui.SetCursorPos(imgui.ImVec2(161, 25))
        if imgui.Button('Vehicle', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 4
        end
        imgui.SetCursorPos(imgui.ImVec2(213, 25))
        if imgui.Button('Config', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 5
        end
        imgui.SetCursorPos(imgui.ImVec2(265, 25))
        if imgui.Button('Console', imgui.ImVec2(50, 24)) then
            GUI.currentButtonID = 6
        end
            imgui.SetCursorPos(imgui.ImVec2(317,24))
            if imgui.Button('Settings', imgui.ImVec2(50,24)) then
                GUI.currentButtonID = 7
        end
        if GUI.currentButtonID == 1 then
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('Smooth', GUI.aimbot.Smooth, 1.0, 25.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('Radius', GUI.aimbot.Radius, 1.0, 300.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SafeZone', GUI.aimbot.Safe, 1.0, 300.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SuperSmooth', GUI.aimbot.SuperSmooth, 1.0, 25.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.Checkbox('Enable', GUI.aimbot.Enable)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('IsFire', GUI.aimbot.IsFire)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('VisibleCheck', GUI.aimbot.VisibleCheck)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('DynamicSmooth', GUI.aimbot.DynamicSmooth)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('CFilter', GUI.aimbot.CFilter)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('IgnoreRange', GUI.aimbot.IgnoreRange)
            imgui.SetCursorPos(imgui.ImVec2(150, 149))
            imgui.Checkbox('IgnoreStun', GUI.aimbot.IgnoreStun)
        end
        if GUI.currentButtonID == 2 then
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Line', GUI.visual.ESPLine)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Bones', GUI.visual.ESPBones)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Box', GUI.visual.ESPBox)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('ESP Info', GUI.visual.ESPInfo)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('Draw FOV', GUI.visual.DrawFOV)
        end
        if GUI.currentButtonID == 3 then
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoStun', GUI.actor.NoStun)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoFall', GUI.actor.NoFall)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('NoCamRestore', GUI.actor.NoCamRestore)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('InfiniteRun', GUI.actor.InfiniteRun)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('GodMode', GUI.actor.GodMode)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('AirBreak', GUI.actor.AirBreak)
        end
        if GUI.currentButtonID == 4 then
            imgui.SetCursorPosX(5)
            imgui.SliderFloat('SpeedSmooth', GUI.vehicle.SpeedSmooth, 1.0, 30.0, "%.1f")
            imgui.SetCursorPosX(5)
            imgui.Checkbox('SpeedHack', GUI.vehicle.SpeedHack)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('DriveInWater', GUI.vehicle.Drive)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('FastExit', GUI.vehicle.FastExit)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('JumpBMX', GUI.vehicle.JumpBMX)
            imgui.SetCursorPosX(5)
            imgui.Checkbox('BikeFall', GUI.vehicle.BikeFall)
        end
        if GUI.currentButtonID == 5 then
            imgui.SetCursorPosX(5)
            if imgui.Button('Load', imgui.ImVec2(310, 25)) then load_ini() end
            imgui.SetCursorPosX(5)
            if imgui.Button('Save', imgui.ImVec2(310, 25)) then save_ini() end
            imgui.SetCursorPosX(5)
            if imgui.Button('Reset', imgui.ImVec2(310, 25)) then reset_ini() end
              end
               if GUI.currentButtonID == 6 then
               imgui.SetCursorPosX(5)
               imgui.InputText('Input', input)
               imgui.SetCursorPosX(5)
                if imgui.Button('Send') then
                   if input.v == 'DEATH' or input.v == 'death' then
                    setCharHealth(PLAYER_PED, 0)
                end
                if input.v == 'RECON' or input.v == 'recon' then
                    local ip, port = sampGetCurrentServerAddress()
                    sampDisconnectWithReason(false)
                    sampConnectToServer(ip, port)
                end
                if input.v == 'RELOAD' or input.v == 'reload' then
                    sampToggleCursor(false)
                    showCursor(false)
                    thisScript():reload()
                end
                    if input.v == 'UPDATES' or input.v == 'updates' then
                        sampSendChat("/updates")
                end
                input.v = ''
            end
            imgui.Text('All comands:\n\nDEATH\nRECON\nRELOAD\nUPDATES(Very Soon...)')
        end
        if GUI.currentButtonID == 7 then
            imgui.Separator()
            if imgui.TreeNode(u8'Сменить тему') then
                if HLcfg.main.theme ~= 1 then apply_custom_style() end
                if imgui.Button(u8'Темная тема') then HLcfg.main.theme = 1; apply_custom_style() end
                GetTheme()
                if HLcfg.main.theme ~= 2 then lightBlue() end
                if imgui.Button(u8'Светло-синяя тема', imgui.SameLine()) then HLcfg.main.theme = 2; lightBlue() end
                GetTheme()
                if HLcfg.main.theme ~= 3 then redTheme() end
                if imgui.Button(u8'Красная тема', imgui.SameLine()) then HLcfg.main.theme = 3; redTheme() end
                GetTheme()
                imgui.TreePop()
            end
            imgui.End()
        end
    end
end
 

Morse

Потрачен
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
сделай текст переменной
Создал local nbutton = u8"Выдача..." и дальше как?

Lua:
if imgui.Button(u8"123") then
--шо тут
end
Как выровнять текст поцентру в begin не юзая пробел?
Lua:
imgui.Begin("название", main_window)

--main_window это то что ты регестрировал в начале, типо main_window = ImBool(false)
--main_window может быть не main_window, а то что ты указал в начале, надеюсь ты понял меня
 
  • Нравится
Реакции: PoundFoolish

danywa

Активный
358
50
Есть в луа аналог ракботовской функции с 'подключен ли игрок серверу' по нику
Нашел я только по ид
Lua:
sampIsPlayerConnected
 

Next..

Известный
343
135
Создал local nbutton = u8"Выдача..." и дальше как?

Lua:
if imgui.Button(u8"123") then
--шо тут
end

Lua:
imgui.Begin("название", main_window)

--main_window это то что ты регестрировал в начале, типо main_window = ImBool(false)
--main_window может быть не main_window, а то что ты указал в начале, надеюсь ты понял меня
Lua:
local butt = 'qq'

if imgui.Button(butt) then
        butt = 'hi'
end
 
  • Влюблен
Реакции: Morse

Morse

Потрачен
436
70
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Lua:
local butt = 'qq'

if imgui.Button(butt) then
        butt = 'hi'
end

imgui.SameLine()
А не знаешь как, крч
у меня есть imgui.InputTextMultiline и мне надо сделать что бы кнопка меняла название при нажатии и потом как выдастся последняя строка из imgui.InputTextMultiline поменять обратно, примерно понимаю, что нужно сделать проверку в чате на отправку последней строки, только не понимаю, как это можно сделать. Поможешь?)
 

moreveal

Известный
Проверенный
859
538
Есть в луа аналог ракботовской функции с 'подключен ли игрок серверу' по нику
Нашел я только по ид
Lua:
sampIsPlayerConnected
Lua:
function sampGetPlayerIdByNickname(nick)
    local myid = select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))
    if tostring(nick) == sampGetPlayerNickname(myid) then return myid end
    for i = 0, sampGetMaxPlayerId() do if sampIsPlayerConnected(i) and sampGetPlayerNickname(i) == tostring(nick) then return i end end
    return -1
end

sampIsPlayerConnected(sampGetPlayerIdByNickname('Nick_Name'))