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

DiteD331

Участник
99
13
Как я понимаю, нужная мне херня находится в подразделе CHAT BUBBLE.

Lua:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local window = imgui.ImBool(false)

local settings = {
    id = imgui.ImInt(-1),
    lvl = imgui.ImInt(-1),
    skin = imgui.ImInt(-1),
    originalName = imgui.ImBuffer(25),
    name = imgui.ImBuffer(25),
    message = imgui.ImBuffer(1000),
    bubble = imgui.ImBool(true),
    bubbletime = imgui.ImInt(5),
    cheatcode = imgui.ImBuffer('plf', 20),
    uid = imgui.ImInt(-1),
    packetloss = imgui.ImInt(38),
    client = imgui.ImInt(0),
}
math.randomseed(os.clock())
settings.uid.v = math.random(10000, 100000)
settings.packetloss.v = math.random(1, 100)
local clientlist = {[0] = 'лаунчер', [1] = 'клиент', [2] = 'мобильный лаунчер'}



local sampev = require 'lib.samp.events'

function sampev.onSendCommand(text)
    if text:find('/id (.+)') then
        if settings.id.v ~= -1 then
            local player = text:match('/id (.+)')
            if player == tostring(settings.id.v) then
                math.randomseed(os.clock())
sampAddChatMessage('['..settings.id.v..'] '..settings.name.v..' | LVL: '..settings.lvl.v..'', -1)
                
                return false
            end
        end
    elseif text:find('/plf') then
        window.v = not window.v
        return false
    end
end

function main()
    while not isSampAvailable() do wait(200) end
    imgui.Process = false
    window.v = false  --show window
    while true do
        wait(0)
        imgui.Process = window.v
        if testCheat(settings.cheatcode.v) then
            sendMessages()
        end
    end
end

function imgui.OnDrawFrame()
    if window.v then
        local resX, resY = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - 150, resY / 2 - 200), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.Begin('FakePlayer by chapo', window, imgui.WindowFlags.NoResize)

        imgui.offset(u8'ID игрока: ')
        if imgui.InputInt('##id', settings.id) then
            if sampIsPlayerConnected(settings.id.v) then
                settings.lvl.v = sampGetPlayerScore(settings.id.v)
                settings.name.v = sampGetPlayerNickname(settings.id.v)
                result, ped = sampGetCharHandleBySampPlayerId(settings.id.v)
                if result then
                    settings.skin.v = getCharModel(ped)
                end
                math.randomseed(os.clock())
                settings.uid.v = math.random(10000, 100000)
                settings.packetloss.v = math.random(1, 100)
                
            else
                settings.lvl.v = -1
                settings.name.v = 'Not Connected!'
                settings.skin.v = -1
            end
        end

        imgui.Separator()

        if sampIsPlayerConnected(settings.id.v) then

            imgui.offset(u8'Ник игрока: ')
            if imgui.InputText('##name', settings.name) then setPlayerSettings() end

            imgui.offset(u8'Скин игрока: ')
            if imgui.InputInt('##skin', settings.skin) then setPlayerSettings() end

            imgui.offset(u8'LVL игрока: ')
            if imgui.InputInt('##lvl', settings.lvl) then setPlayerSettings() end
            
            imgui.SetCursorPosX(5)
            imgui.InputTextMultiline('##MSG', settings.message, imgui.ImVec2(290, 100))
            if imgui.IsItemHovered() then
                imgui.BeginTooltip()
                    imgui.Text(u8'Использование:\nсообщение без префиксов - фейк сообщение\nwait:[время(мс)] - ожидание в миллисекундах\n/do:[текст] - фейк /do\n/me:[текст] - фейк /me')
                imgui.EndTooltip()
            end

            imgui.Checkbox(u8'Отображать текст над головой', settings.bubble)
            if settings.bubble.v then
                imgui.SameLine()
                imgui.PushItemWidth(83)
                imgui.InputInt('##bubbletime', settings.bubbletime)
                imgui.PopItemWidth()
                if imgui.IsItemHovered() then
                    imgui.BeginTooltip()
                        imgui.Text(u8'Длительность отображение текста над головой (секунды)')
                    imgui.EndTooltip()
                end
            end

            imgui.offset(u8'Чит-код для начала отправки:')
            imgui.SetCursorPosX(185)
            imgui.PushItemWidth(110)
            imgui.InputText('##startcode', settings.cheatcode)
            imgui.PopItemWidth()
            --if imgui.Button('send', imgui.ImVec2(100, 20)) then sendMessages() end

            imgui.Separator()
            imgui.SetCursorPosX(imgui.GetWindowSize().x / 2 - imgui.CalcTextSize(u8'Настройки /id '..tostring(settings.id.v)).x / 2)
            imgui.Text(u8'Настройки /id '..tostring(settings.id.v))

            imgui.offset(u8'Платформа: ')
            imgui.Combo(u8'##С чего играет?', settings.client, {u8'лаунчер', u8'клиент', u8'мобилка'}, -1)
            imgui.offset(u8'UID: ') imgui.InputInt('##uid', settings.uid)
            imgui.offset(u8'Packetloss: ') imgui.SliderInt('##p_loss', settings.packetloss, 1, 100)
            

        else
            imgui.NewLine()
            imgui.SetCursorPosX(imgui.GetWindowSize().x / 2 - imgui.CalcTextSize(u8'Игрок не найден!').x / 2)
            imgui.Text(u8'Игрок не найден!')
        end

        imgui.SetCursorPos(imgui.ImVec2(5, 375))
        if imgui.Button(u8'Сохранить и закрыть', imgui.ImVec2(290, 20)) then
            window.v = false
        end

        imgui.End()
    end
end

function imgui.offset(text)
    local offset = 100
    imgui.Text(text)
    imgui.SameLine()
    imgui.SetCursorPosX(offset)
end

--function go()
--    flvl(input_playerid.v, input_fakelvl.v)
--    fname(input_playerid.v, input_fakename.v)
--    fchat(input_playerid.v, u8:decode(input_fakemsg.v))
--    fskin(input_playerid.v, input_fakeskin.v)
--end

function setPlayerSettings()
    local playerId = settings.id.v
    local name = settings.name.v
    local skin = settings.skin.v
    local lvl = settings.lvl.v
    --==[LVL]==--
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt16(bs, playerId)  -- id
    raknetBitStreamWriteInt32(bs, lvl)  -- lvl
    raknetBitStreamWriteInt32(bs, sampGetPlayerPing(id))  -- ping
    raknetEmulRpcReceiveBitStream(155, bs)
    raknetDeleteBitStream(bs)

    --==[NAME]==--
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt16(bs, playerId)  -- id
    raknetBitStreamWriteInt8(bs, #name)  -- name len
    raknetBitStreamWriteString(bs, name)  -- name
    raknetBitStreamWriteInt8(bs, 1)  -- unknown
    raknetEmulRpcReceiveBitStream(11, bs)
    raknetDeleteBitStream(bs)
    
    --==[SKIN]==--
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt32(bs, playerId)    --playerId
    raknetBitStreamWriteInt32(bs, skin)      --skinId
    raknetEmulRpcReceiveBitStream(153, bs)
    raknetDeleteBitStream(bs)
end

function sampev.onUpdateScoresAndPings(data)
    if data[settings.id.v] then
        data[settings.id.v].score = settings.lvl.v
        return {data}
    end
end

-- 1182971135    do_text  - |  chapo_lua[53]
-- -6684673   chapo_lua[53] me_text
-- -1   {FFFFFF}chapo_lua[53] говорит:{B7AFAF}  def_text
-- chapo_lua[43] (( {FFE6E6}b_text{FFFFFF} ))


function sendMessages()
    local playerId = settings.id.v
    local fulltext = settings.message.v
    local text = 'var_type_string'
    local name = sampGetPlayerNickname(playerId)
    lua_thread.create(function()
        for v in string.gmatch(fulltext, '[^\n]+') do
            if v:find('wait:(.+)') then
                local waitTime = v:match('wait:(.+)')
                wait(tonumber(waitTime))
            else
                if v:find('/b:(.+)') then
                    text = v:match('/b:(.+)')
                    sampAddChatMessage(name..'['..playerId..'] (( {FFFFFF}'..u8:decode(text)..'{FFFFFF} ))', -1)
                elseif v:find('/me:(.+)') then
                    text = v:match('/me:(.+)')
                    msg(name..'['..playerId..'] '..u8:decode(text), -6684673)
                elseif v:find('/do:(.+)') then
                    text = v:match('/do:(.+)')
                    msg(u8:decode(text)..'  - |  '..name..'['..playerId..']', 1182971135)
                elseif v:find('/r:(.+)') then
                    text = v:match('/r:(.+)')
                    msg(u8:decode(text), 766526463)
                else
                    text = v
                    sampAddChatMessage(name..'['..playerId..'] говорит:{FFFFFF} '..u8:decode(text), -1)

                    --==[CHAT BUBBLE]==--
                    if settings.bubble.v then
                        bs1 = raknetNewBitStream()
                        raknetBitStreamWriteInt16(bs1, playerId)      --player id
                        raknetBitStreamWriteInt32(bs1, -1)      --color
                        raknetBitStreamWriteFloat(bs1, 15)      --distance
                        raknetBitStreamWriteInt32(bs1, settings.bubbletime.v * 1000)   --time
                        raknetBitStreamWriteInt8(bs1, #u8:decode(text))     --len
                        raknetBitStreamWriteString(bs1, u8:decode(text))    --msg
                        raknetEmulRpcReceiveBitStream(59, bs1)
                        raknetDeleteBitStream(bs1)
                    end
                end

                --==[TALK ANIMATION]==--
                result, ped = sampGetCharHandleBySampPlayerId(settings.id.v)
                if result then
                    result2 = doesCharExist(ped)
                    if result2 then
                        taskPlayAnim(ped, 'IDLE_CHAT', 'PED', 4.0999999046326, false, true, true, true, 1)
                    end
                end
            end
        end
    end)
end

function msg(text, color)
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt32(bs, color)
    raknetBitStreamWriteInt32(bs, #text) --msg len
    raknetBitStreamWriteString(bs, text) --msg
    raknetEmulRpcReceiveBitStream(93, bs)
    raknetDeleteBitStream(bs)
end

function BH_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 = ImVec2(6, 4)
    style.WindowRounding = 5.0
    style.ChildWindowRounding = 5.0
    style.FramePadding = ImVec2(5, 2)
    style.FrameRounding = 5.0
    style.ItemSpacing = ImVec2(7, 5)
    style.ItemInnerSpacing = ImVec2(1, 1)
    style.TouchExtraPadding = ImVec2(0, 0)
    style.IndentSpacing = 6.0
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 5.0
    style.GrabMinSize = 20.0
    style.GrabRounding = 2.0
    style.WindowTitleAlign = ImVec2(0.5, 0.5)

    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.28, 0.30, 0.35, 1.00)
    colors[clr.WindowBg]               = ImVec4(0.16, 0.18, 0.22, 1.00)
    colors[clr.ChildWindowBg]          = ImVec4(0.19, 0.22, 0.26, 1)
    colors[clr.PopupBg]                = ImVec4(0.05, 0.05, 0.10, 0.90)
    colors[clr.Border]                 = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]                = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.FrameBgHovered]         = ImVec4(0.22, 0.25, 0.30, 1.00)
    colors[clr.FrameBgActive]          = ImVec4(0.22, 0.25, 0.29, 1.00)
    colors[clr.TitleBg]                = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.19, 0.22, 0.26, 0.59)
    colors[clr.MenuBarBg]              = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.20, 0.25, 0.30, 0.60)
    colors[clr.ScrollbarGrab]          = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.49, 0.63, 0.86, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.49, 0.63, 0.86, 1.00)
    colors[clr.ComboBg]                = ImVec4(0.20, 0.20, 0.20, 0.99)
    colors[clr.CheckMark]              = ImVec4(0.90, 0.90, 0.90, 0.50)
    colors[clr.SliderGrab]             = ImVec4(1.00, 1.00, 1.00, 0.30)
    colors[clr.SliderGrabActive]       = ImVec4(0.80, 0.50, 0.50, 1.00)
    colors[clr.Button]                 = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ButtonHovered]          = ImVec4(0.49, 0.62, 0.85, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.49, 0.62, 0.85, 1.00)
    colors[clr.Header]                 = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.HeaderHovered]          = ImVec4(0.22, 0.24, 0.28, 1.00)
    colors[clr.HeaderActive]           = ImVec4(0.22, 0.24, 0.28, 1.00)
    colors[clr.Separator]              = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.SeparatorHovered]       = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.SeparatorActive]        = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ResizeGripHovered]      = ImVec4(0.49, 0.61, 0.83, 1.00)
    colors[clr.ResizeGripActive]       = ImVec4(0.49, 0.62, 0.83, 1.00)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.CloseButtonHovered]     = ImVec4(0.50, 0.63, 0.84, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.PlotLines]              = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(0.90, 0.70, 0.00, 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.TextSelectedBg]         = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.16, 0.18, 0.22, 0.76)
end
BH_theme()
 

вайега52

Налуашил состояние
Модератор
2,900
2,910
Как я понимаю, нужная мне херня находится в подразделе CHAT BUBBLE.

Lua:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local window = imgui.ImBool(false)

local settings = {
    id = imgui.ImInt(-1),
    lvl = imgui.ImInt(-1),
    skin = imgui.ImInt(-1),
    originalName = imgui.ImBuffer(25),
    name = imgui.ImBuffer(25),
    message = imgui.ImBuffer(1000),
    bubble = imgui.ImBool(true),
    bubbletime = imgui.ImInt(5),
    cheatcode = imgui.ImBuffer('plf', 20),
    uid = imgui.ImInt(-1),
    packetloss = imgui.ImInt(38),
    client = imgui.ImInt(0),
}
math.randomseed(os.clock())
settings.uid.v = math.random(10000, 100000)
settings.packetloss.v = math.random(1, 100)
local clientlist = {[0] = 'лаунчер', [1] = 'клиент', [2] = 'мобильный лаунчер'}



local sampev = require 'lib.samp.events'

function sampev.onSendCommand(text)
    if text:find('/id (.+)') then
        if settings.id.v ~= -1 then
            local player = text:match('/id (.+)')
            if player == tostring(settings.id.v) then
                math.randomseed(os.clock())
sampAddChatMessage('['..settings.id.v..'] '..settings.name.v..' | LVL: '..settings.lvl.v..'', -1)
               
                return false
            end
        end
    elseif text:find('/plf') then
        window.v = not window.v
        return false
    end
end

function main()
    while not isSampAvailable() do wait(200) end
    imgui.Process = false
    window.v = false  --show window
    while true do
        wait(0)
        imgui.Process = window.v
        if testCheat(settings.cheatcode.v) then
            sendMessages()
        end
    end
end

function imgui.OnDrawFrame()
    if window.v then
        local resX, resY = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - 150, resY / 2 - 200), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.Begin('FakePlayer by chapo', window, imgui.WindowFlags.NoResize)

        imgui.offset(u8'ID игрока: ')
        if imgui.InputInt('##id', settings.id) then
            if sampIsPlayerConnected(settings.id.v) then
                settings.lvl.v = sampGetPlayerScore(settings.id.v)
                settings.name.v = sampGetPlayerNickname(settings.id.v)
                result, ped = sampGetCharHandleBySampPlayerId(settings.id.v)
                if result then
                    settings.skin.v = getCharModel(ped)
                end
                math.randomseed(os.clock())
                settings.uid.v = math.random(10000, 100000)
                settings.packetloss.v = math.random(1, 100)
               
            else
                settings.lvl.v = -1
                settings.name.v = 'Not Connected!'
                settings.skin.v = -1
            end
        end

        imgui.Separator()

        if sampIsPlayerConnected(settings.id.v) then

            imgui.offset(u8'Ник игрока: ')
            if imgui.InputText('##name', settings.name) then setPlayerSettings() end

            imgui.offset(u8'Скин игрока: ')
            if imgui.InputInt('##skin', settings.skin) then setPlayerSettings() end

            imgui.offset(u8'LVL игрока: ')
            if imgui.InputInt('##lvl', settings.lvl) then setPlayerSettings() end
           
            imgui.SetCursorPosX(5)
            imgui.InputTextMultiline('##MSG', settings.message, imgui.ImVec2(290, 100))
            if imgui.IsItemHovered() then
                imgui.BeginTooltip()
                    imgui.Text(u8'Использование:\nсообщение без префиксов - фейк сообщение\nwait:[время(мс)] - ожидание в миллисекундах\n/do:[текст] - фейк /do\n/me:[текст] - фейк /me')
                imgui.EndTooltip()
            end

            imgui.Checkbox(u8'Отображать текст над головой', settings.bubble)
            if settings.bubble.v then
                imgui.SameLine()
                imgui.PushItemWidth(83)
                imgui.InputInt('##bubbletime', settings.bubbletime)
                imgui.PopItemWidth()
                if imgui.IsItemHovered() then
                    imgui.BeginTooltip()
                        imgui.Text(u8'Длительность отображение текста над головой (секунды)')
                    imgui.EndTooltip()
                end
            end

            imgui.offset(u8'Чит-код для начала отправки:')
            imgui.SetCursorPosX(185)
            imgui.PushItemWidth(110)
            imgui.InputText('##startcode', settings.cheatcode)
            imgui.PopItemWidth()
            --if imgui.Button('send', imgui.ImVec2(100, 20)) then sendMessages() end

            imgui.Separator()
            imgui.SetCursorPosX(imgui.GetWindowSize().x / 2 - imgui.CalcTextSize(u8'Настройки /id '..tostring(settings.id.v)).x / 2)
            imgui.Text(u8'Настройки /id '..tostring(settings.id.v))

            imgui.offset(u8'Платформа: ')
            imgui.Combo(u8'##С чего играет?', settings.client, {u8'лаунчер', u8'клиент', u8'мобилка'}, -1)
            imgui.offset(u8'UID: ') imgui.InputInt('##uid', settings.uid)
            imgui.offset(u8'Packetloss: ') imgui.SliderInt('##p_loss', settings.packetloss, 1, 100)
           

        else
            imgui.NewLine()
            imgui.SetCursorPosX(imgui.GetWindowSize().x / 2 - imgui.CalcTextSize(u8'Игрок не найден!').x / 2)
            imgui.Text(u8'Игрок не найден!')
        end

        imgui.SetCursorPos(imgui.ImVec2(5, 375))
        if imgui.Button(u8'Сохранить и закрыть', imgui.ImVec2(290, 20)) then
            window.v = false
        end

        imgui.End()
    end
end

function imgui.offset(text)
    local offset = 100
    imgui.Text(text)
    imgui.SameLine()
    imgui.SetCursorPosX(offset)
end

--function go()
--    flvl(input_playerid.v, input_fakelvl.v)
--    fname(input_playerid.v, input_fakename.v)
--    fchat(input_playerid.v, u8:decode(input_fakemsg.v))
--    fskin(input_playerid.v, input_fakeskin.v)
--end

function setPlayerSettings()
    local playerId = settings.id.v
    local name = settings.name.v
    local skin = settings.skin.v
    local lvl = settings.lvl.v
    --==[LVL]==--
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt16(bs, playerId)  -- id
    raknetBitStreamWriteInt32(bs, lvl)  -- lvl
    raknetBitStreamWriteInt32(bs, sampGetPlayerPing(id))  -- ping
    raknetEmulRpcReceiveBitStream(155, bs)
    raknetDeleteBitStream(bs)

    --==[NAME]==--
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt16(bs, playerId)  -- id
    raknetBitStreamWriteInt8(bs, #name)  -- name len
    raknetBitStreamWriteString(bs, name)  -- name
    raknetBitStreamWriteInt8(bs, 1)  -- unknown
    raknetEmulRpcReceiveBitStream(11, bs)
    raknetDeleteBitStream(bs)
   
    --==[SKIN]==--
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt32(bs, playerId)    --playerId
    raknetBitStreamWriteInt32(bs, skin)      --skinId
    raknetEmulRpcReceiveBitStream(153, bs)
    raknetDeleteBitStream(bs)
end

function sampev.onUpdateScoresAndPings(data)
    if data[settings.id.v] then
        data[settings.id.v].score = settings.lvl.v
        return {data}
    end
end

-- 1182971135    do_text  - |  chapo_lua[53]
-- -6684673   chapo_lua[53] me_text
-- -1   {FFFFFF}chapo_lua[53] говорит:{B7AFAF}  def_text
-- chapo_lua[43] (( {FFE6E6}b_text{FFFFFF} ))


function sendMessages()
    local playerId = settings.id.v
    local fulltext = settings.message.v
    local text = 'var_type_string'
    local name = sampGetPlayerNickname(playerId)
    lua_thread.create(function()
        for v in string.gmatch(fulltext, '[^\n]+') do
            if v:find('wait:(.+)') then
                local waitTime = v:match('wait:(.+)')
                wait(tonumber(waitTime))
            else
                if v:find('/b:(.+)') then
                    text = v:match('/b:(.+)')
                    sampAddChatMessage(name..'['..playerId..'] (( {FFFFFF}'..u8:decode(text)..'{FFFFFF} ))', -1)
                elseif v:find('/me:(.+)') then
                    text = v:match('/me:(.+)')
                    msg(name..'['..playerId..'] '..u8:decode(text), -6684673)
                elseif v:find('/do:(.+)') then
                    text = v:match('/do:(.+)')
                    msg(u8:decode(text)..'  - |  '..name..'['..playerId..']', 1182971135)
                elseif v:find('/r:(.+)') then
                    text = v:match('/r:(.+)')
                    msg(u8:decode(text), 766526463)
                else
                    text = v
                    sampAddChatMessage(name..'['..playerId..'] говорит:{FFFFFF} '..u8:decode(text), -1)

                    --==[CHAT BUBBLE]==--
                    if settings.bubble.v then
                        bs1 = raknetNewBitStream()
                        raknetBitStreamWriteInt16(bs1, playerId)      --player id
                        raknetBitStreamWriteInt32(bs1, -1)      --color
                        raknetBitStreamWriteFloat(bs1, 15)      --distance
                        raknetBitStreamWriteInt32(bs1, settings.bubbletime.v * 1000)   --time
                        raknetBitStreamWriteInt8(bs1, #u8:decode(text))     --len
                        raknetBitStreamWriteString(bs1, u8:decode(text))    --msg
                        raknetEmulRpcReceiveBitStream(59, bs1)
                        raknetDeleteBitStream(bs1)
                    end
                end

                --==[TALK ANIMATION]==--
                result, ped = sampGetCharHandleBySampPlayerId(settings.id.v)
                if result then
                    result2 = doesCharExist(ped)
                    if result2 then
                        taskPlayAnim(ped, 'IDLE_CHAT', 'PED', 4.0999999046326, false, true, true, true, 1)
                    end
                end
            end
        end
    end)
end

function msg(text, color)
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt32(bs, color)
    raknetBitStreamWriteInt32(bs, #text) --msg len
    raknetBitStreamWriteString(bs, text) --msg
    raknetEmulRpcReceiveBitStream(93, bs)
    raknetDeleteBitStream(bs)
end

function BH_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 = ImVec2(6, 4)
    style.WindowRounding = 5.0
    style.ChildWindowRounding = 5.0
    style.FramePadding = ImVec2(5, 2)
    style.FrameRounding = 5.0
    style.ItemSpacing = ImVec2(7, 5)
    style.ItemInnerSpacing = ImVec2(1, 1)
    style.TouchExtraPadding = ImVec2(0, 0)
    style.IndentSpacing = 6.0
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 5.0
    style.GrabMinSize = 20.0
    style.GrabRounding = 2.0
    style.WindowTitleAlign = ImVec2(0.5, 0.5)

    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.28, 0.30, 0.35, 1.00)
    colors[clr.WindowBg]               = ImVec4(0.16, 0.18, 0.22, 1.00)
    colors[clr.ChildWindowBg]          = ImVec4(0.19, 0.22, 0.26, 1)
    colors[clr.PopupBg]                = ImVec4(0.05, 0.05, 0.10, 0.90)
    colors[clr.Border]                 = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]                = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.FrameBgHovered]         = ImVec4(0.22, 0.25, 0.30, 1.00)
    colors[clr.FrameBgActive]          = ImVec4(0.22, 0.25, 0.29, 1.00)
    colors[clr.TitleBg]                = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.19, 0.22, 0.26, 0.59)
    colors[clr.MenuBarBg]              = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.20, 0.25, 0.30, 0.60)
    colors[clr.ScrollbarGrab]          = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.49, 0.63, 0.86, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.49, 0.63, 0.86, 1.00)
    colors[clr.ComboBg]                = ImVec4(0.20, 0.20, 0.20, 0.99)
    colors[clr.CheckMark]              = ImVec4(0.90, 0.90, 0.90, 0.50)
    colors[clr.SliderGrab]             = ImVec4(1.00, 1.00, 1.00, 0.30)
    colors[clr.SliderGrabActive]       = ImVec4(0.80, 0.50, 0.50, 1.00)
    colors[clr.Button]                 = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ButtonHovered]          = ImVec4(0.49, 0.62, 0.85, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.49, 0.62, 0.85, 1.00)
    colors[clr.Header]                 = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.HeaderHovered]          = ImVec4(0.22, 0.24, 0.28, 1.00)
    colors[clr.HeaderActive]           = ImVec4(0.22, 0.24, 0.28, 1.00)
    colors[clr.Separator]              = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.SeparatorHovered]       = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.SeparatorActive]        = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ResizeGripHovered]      = ImVec4(0.49, 0.61, 0.83, 1.00)
    colors[clr.ResizeGripActive]       = ImVec4(0.49, 0.62, 0.83, 1.00)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.CloseButtonHovered]     = ImVec4(0.50, 0.63, 0.84, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.PlotLines]              = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(0.90, 0.70, 0.00, 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.TextSelectedBg]         = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.16, 0.18, 0.22, 0.76)
end
BH_theme()
При выводе текста в строку добавляй HEX код цвета в подобном виде: {......}, например: {FF00FF}. Коды можешь посмотреть в интернете
 

DiteD331

Участник
99
13
При выводе текста в строку добавляй HEX код цвета в подобном виде: {......}, например: {FF00FF}. Коды можешь посмотреть в интернете
Я не нашёл строку, которая была бы связана с нужной мне хернёй и кодом HEX. Скорее всего, ты имеешь ввиду подраздел, который отвечает за то, чтобы отправлять написанные сообщения в чат, и каким цветом они должны быть.
 

вайега52

Налуашил состояние
Модератор
2,900
2,910
Я не нашёл строку, которая была бы связана с нужной мне хернёй и кодом HEX. Скорее всего, ты имеешь ввиду подраздел, который отвечает за то, чтобы отправлять написанные сообщения в чат, и каким цветом они должны быть.
Если необходимо для всего сообщения, то можешь в 242 строке изменить -1 на нужный цвет (например 0xFF00FF)
 
  • Нравится
Реакции: DiteD331 и plalkeo

plalkeo

Известный
869
351
Как я понимаю, нужная мне херня находится в подразделе CHAT BUBBLE.

Lua:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local window = imgui.ImBool(false)

local settings = {
    id = imgui.ImInt(-1),
    lvl = imgui.ImInt(-1),
    skin = imgui.ImInt(-1),
    originalName = imgui.ImBuffer(25),
    name = imgui.ImBuffer(25),
    message = imgui.ImBuffer(1000),
    bubble = imgui.ImBool(true),
    bubbletime = imgui.ImInt(5),
    cheatcode = imgui.ImBuffer('plf', 20),
    uid = imgui.ImInt(-1),
    packetloss = imgui.ImInt(38),
    client = imgui.ImInt(0),
}
math.randomseed(os.clock())
settings.uid.v = math.random(10000, 100000)
settings.packetloss.v = math.random(1, 100)
local clientlist = {[0] = 'лаунчер', [1] = 'клиент', [2] = 'мобильный лаунчер'}



local sampev = require 'lib.samp.events'

function sampev.onSendCommand(text)
    if text:find('/id (.+)') then
        if settings.id.v ~= -1 then
            local player = text:match('/id (.+)')
            if player == tostring(settings.id.v) then
                math.randomseed(os.clock())
sampAddChatMessage('['..settings.id.v..'] '..settings.name.v..' | LVL: '..settings.lvl.v..'', -1)
               
                return false
            end
        end
    elseif text:find('/plf') then
        window.v = not window.v
        return false
    end
end

function main()
    while not isSampAvailable() do wait(200) end
    imgui.Process = false
    window.v = false  --show window
    while true do
        wait(0)
        imgui.Process = window.v
        if testCheat(settings.cheatcode.v) then
            sendMessages()
        end
    end
end

function imgui.OnDrawFrame()
    if window.v then
        local resX, resY = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - 150, resY / 2 - 200), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(300.0, 400.0), imgui.Cond.FirstUseEver)
        imgui.Begin('FakePlayer by chapo', window, imgui.WindowFlags.NoResize)

        imgui.offset(u8'ID игрока: ')
        if imgui.InputInt('##id', settings.id) then
            if sampIsPlayerConnected(settings.id.v) then
                settings.lvl.v = sampGetPlayerScore(settings.id.v)
                settings.name.v = sampGetPlayerNickname(settings.id.v)
                result, ped = sampGetCharHandleBySampPlayerId(settings.id.v)
                if result then
                    settings.skin.v = getCharModel(ped)
                end
                math.randomseed(os.clock())
                settings.uid.v = math.random(10000, 100000)
                settings.packetloss.v = math.random(1, 100)
               
            else
                settings.lvl.v = -1
                settings.name.v = 'Not Connected!'
                settings.skin.v = -1
            end
        end

        imgui.Separator()

        if sampIsPlayerConnected(settings.id.v) then

            imgui.offset(u8'Ник игрока: ')
            if imgui.InputText('##name', settings.name) then setPlayerSettings() end

            imgui.offset(u8'Скин игрока: ')
            if imgui.InputInt('##skin', settings.skin) then setPlayerSettings() end

            imgui.offset(u8'LVL игрока: ')
            if imgui.InputInt('##lvl', settings.lvl) then setPlayerSettings() end
           
            imgui.SetCursorPosX(5)
            imgui.InputTextMultiline('##MSG', settings.message, imgui.ImVec2(290, 100))
            if imgui.IsItemHovered() then
                imgui.BeginTooltip()
                    imgui.Text(u8'Использование:\nсообщение без префиксов - фейк сообщение\nwait:[время(мс)] - ожидание в миллисекундах\n/do:[текст] - фейк /do\n/me:[текст] - фейк /me')
                imgui.EndTooltip()
            end

            imgui.Checkbox(u8'Отображать текст над головой', settings.bubble)
            if settings.bubble.v then
                imgui.SameLine()
                imgui.PushItemWidth(83)
                imgui.InputInt('##bubbletime', settings.bubbletime)
                imgui.PopItemWidth()
                if imgui.IsItemHovered() then
                    imgui.BeginTooltip()
                        imgui.Text(u8'Длительность отображение текста над головой (секунды)')
                    imgui.EndTooltip()
                end
            end

            imgui.offset(u8'Чит-код для начала отправки:')
            imgui.SetCursorPosX(185)
            imgui.PushItemWidth(110)
            imgui.InputText('##startcode', settings.cheatcode)
            imgui.PopItemWidth()
            --if imgui.Button('send', imgui.ImVec2(100, 20)) then sendMessages() end

            imgui.Separator()
            imgui.SetCursorPosX(imgui.GetWindowSize().x / 2 - imgui.CalcTextSize(u8'Настройки /id '..tostring(settings.id.v)).x / 2)
            imgui.Text(u8'Настройки /id '..tostring(settings.id.v))

            imgui.offset(u8'Платформа: ')
            imgui.Combo(u8'##С чего играет?', settings.client, {u8'лаунчер', u8'клиент', u8'мобилка'}, -1)
            imgui.offset(u8'UID: ') imgui.InputInt('##uid', settings.uid)
            imgui.offset(u8'Packetloss: ') imgui.SliderInt('##p_loss', settings.packetloss, 1, 100)
           

        else
            imgui.NewLine()
            imgui.SetCursorPosX(imgui.GetWindowSize().x / 2 - imgui.CalcTextSize(u8'Игрок не найден!').x / 2)
            imgui.Text(u8'Игрок не найден!')
        end

        imgui.SetCursorPos(imgui.ImVec2(5, 375))
        if imgui.Button(u8'Сохранить и закрыть', imgui.ImVec2(290, 20)) then
            window.v = false
        end

        imgui.End()
    end
end

function imgui.offset(text)
    local offset = 100
    imgui.Text(text)
    imgui.SameLine()
    imgui.SetCursorPosX(offset)
end

--function go()
--    flvl(input_playerid.v, input_fakelvl.v)
--    fname(input_playerid.v, input_fakename.v)
--    fchat(input_playerid.v, u8:decode(input_fakemsg.v))
--    fskin(input_playerid.v, input_fakeskin.v)
--end

function setPlayerSettings()
    local playerId = settings.id.v
    local name = settings.name.v
    local skin = settings.skin.v
    local lvl = settings.lvl.v
    --==[LVL]==--
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt16(bs, playerId)  -- id
    raknetBitStreamWriteInt32(bs, lvl)  -- lvl
    raknetBitStreamWriteInt32(bs, sampGetPlayerPing(id))  -- ping
    raknetEmulRpcReceiveBitStream(155, bs)
    raknetDeleteBitStream(bs)

    --==[NAME]==--
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt16(bs, playerId)  -- id
    raknetBitStreamWriteInt8(bs, #name)  -- name len
    raknetBitStreamWriteString(bs, name)  -- name
    raknetBitStreamWriteInt8(bs, 1)  -- unknown
    raknetEmulRpcReceiveBitStream(11, bs)
    raknetDeleteBitStream(bs)
   
    --==[SKIN]==--
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt32(bs, playerId)    --playerId
    raknetBitStreamWriteInt32(bs, skin)      --skinId
    raknetEmulRpcReceiveBitStream(153, bs)
    raknetDeleteBitStream(bs)
end

function sampev.onUpdateScoresAndPings(data)
    if data[settings.id.v] then
        data[settings.id.v].score = settings.lvl.v
        return {data}
    end
end

-- 1182971135    do_text  - |  chapo_lua[53]
-- -6684673   chapo_lua[53] me_text
-- -1   {FFFFFF}chapo_lua[53] говорит:{B7AFAF}  def_text
-- chapo_lua[43] (( {FFE6E6}b_text{FFFFFF} ))


function sendMessages()
    local playerId = settings.id.v
    local fulltext = settings.message.v
    local text = 'var_type_string'
    local name = sampGetPlayerNickname(playerId)
    lua_thread.create(function()
        for v in string.gmatch(fulltext, '[^\n]+') do
            if v:find('wait:(.+)') then
                local waitTime = v:match('wait:(.+)')
                wait(tonumber(waitTime))
            else
                if v:find('/b:(.+)') then
                    text = v:match('/b:(.+)')
                    sampAddChatMessage(name..'['..playerId..'] (( {FFFFFF}'..u8:decode(text)..'{FFFFFF} ))', -1)
                elseif v:find('/me:(.+)') then
                    text = v:match('/me:(.+)')
                    msg(name..'['..playerId..'] '..u8:decode(text), -6684673)
                elseif v:find('/do:(.+)') then
                    text = v:match('/do:(.+)')
                    msg(u8:decode(text)..'  - |  '..name..'['..playerId..']', 1182971135)
                elseif v:find('/r:(.+)') then
                    text = v:match('/r:(.+)')
                    msg(u8:decode(text), 766526463)
                else
                    text = v
                    sampAddChatMessage(name..'['..playerId..'] говорит:{FFFFFF} '..u8:decode(text), -1)

                    --==[CHAT BUBBLE]==--
                    if settings.bubble.v then
                        bs1 = raknetNewBitStream()
                        raknetBitStreamWriteInt16(bs1, playerId)      --player id
                        raknetBitStreamWriteInt32(bs1, -1)      --color
                        raknetBitStreamWriteFloat(bs1, 15)      --distance
                        raknetBitStreamWriteInt32(bs1, settings.bubbletime.v * 1000)   --time
                        raknetBitStreamWriteInt8(bs1, #u8:decode(text))     --len
                        raknetBitStreamWriteString(bs1, u8:decode(text))    --msg
                        raknetEmulRpcReceiveBitStream(59, bs1)
                        raknetDeleteBitStream(bs1)
                    end
                end

                --==[TALK ANIMATION]==--
                result, ped = sampGetCharHandleBySampPlayerId(settings.id.v)
                if result then
                    result2 = doesCharExist(ped)
                    if result2 then
                        taskPlayAnim(ped, 'IDLE_CHAT', 'PED', 4.0999999046326, false, true, true, true, 1)
                    end
                end
            end
        end
    end)
end

function msg(text, color)
    bs = raknetNewBitStream()
    raknetBitStreamWriteInt32(bs, color)
    raknetBitStreamWriteInt32(bs, #text) --msg len
    raknetBitStreamWriteString(bs, text) --msg
    raknetEmulRpcReceiveBitStream(93, bs)
    raknetDeleteBitStream(bs)
end

function BH_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 = ImVec2(6, 4)
    style.WindowRounding = 5.0
    style.ChildWindowRounding = 5.0
    style.FramePadding = ImVec2(5, 2)
    style.FrameRounding = 5.0
    style.ItemSpacing = ImVec2(7, 5)
    style.ItemInnerSpacing = ImVec2(1, 1)
    style.TouchExtraPadding = ImVec2(0, 0)
    style.IndentSpacing = 6.0
    style.ScrollbarSize = 12.0
    style.ScrollbarRounding = 5.0
    style.GrabMinSize = 20.0
    style.GrabRounding = 2.0
    style.WindowTitleAlign = ImVec2(0.5, 0.5)

    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]           = ImVec4(0.28, 0.30, 0.35, 1.00)
    colors[clr.WindowBg]               = ImVec4(0.16, 0.18, 0.22, 1.00)
    colors[clr.ChildWindowBg]          = ImVec4(0.19, 0.22, 0.26, 1)
    colors[clr.PopupBg]                = ImVec4(0.05, 0.05, 0.10, 0.90)
    colors[clr.Border]                 = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]                = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.FrameBgHovered]         = ImVec4(0.22, 0.25, 0.30, 1.00)
    colors[clr.FrameBgActive]          = ImVec4(0.22, 0.25, 0.29, 1.00)
    colors[clr.TitleBg]                = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.19, 0.22, 0.26, 0.59)
    colors[clr.MenuBarBg]              = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.20, 0.25, 0.30, 0.60)
    colors[clr.ScrollbarGrab]          = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.49, 0.63, 0.86, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.49, 0.63, 0.86, 1.00)
    colors[clr.ComboBg]                = ImVec4(0.20, 0.20, 0.20, 0.99)
    colors[clr.CheckMark]              = ImVec4(0.90, 0.90, 0.90, 0.50)
    colors[clr.SliderGrab]             = ImVec4(1.00, 1.00, 1.00, 0.30)
    colors[clr.SliderGrabActive]       = ImVec4(0.80, 0.50, 0.50, 1.00)
    colors[clr.Button]                 = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ButtonHovered]          = ImVec4(0.49, 0.62, 0.85, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.49, 0.62, 0.85, 1.00)
    colors[clr.Header]                 = ImVec4(0.19, 0.22, 0.26, 1.00)
    colors[clr.HeaderHovered]          = ImVec4(0.22, 0.24, 0.28, 1.00)
    colors[clr.HeaderActive]           = ImVec4(0.22, 0.24, 0.28, 1.00)
    colors[clr.Separator]              = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.SeparatorHovered]       = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.SeparatorActive]        = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ResizeGrip]             = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ResizeGripHovered]      = ImVec4(0.49, 0.61, 0.83, 1.00)
    colors[clr.ResizeGripActive]       = ImVec4(0.49, 0.62, 0.83, 1.00)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.CloseButtonHovered]     = ImVec4(0.50, 0.63, 0.84, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.PlotLines]              = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.PlotLinesHovered]       = ImVec4(0.90, 0.70, 0.00, 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.TextSelectedBg]         = ImVec4(0.41, 0.55, 0.78, 1.00)
    colors[clr.ModalWindowDarkening]   = ImVec4(0.16, 0.18, 0.22, 0.76)
end
BH_theme()
Lua:
raknetBitStreamWriteInt32(bs1, -1)      --color
строчка 242
-1 меняешь на нужный цвет в формате 0xFF00FF (FF00FF - на нужный цвет)
 
  • Нравится
Реакции: DiteD331

Minhjhs

Участник
74
24
Помогите, нашёл обновлённый скрипт fisherman
Ошибка в том, что он не может найти эхолот и нажимает на "Квесты" в инвентаре, вместо эхолота, в чём может быть ошибка?
Использую скрипт на лаунчере
Код, где может быть ошибка
Lua:
-- объект Эхлолот, хранит ID текстдрава страницы и ячейки в которой находится
local echolot = {pageTextDrawId = -1, slotTextDrawId = -1}

-- клик на Эхолот
function echolot.click()
    wait(inventoryWait*2)
    sampSendClickTextdraw(echolot.pageTextDrawId)
    wait(inventoryWait*2)
    
    -- проверка на то, что в данной ячейке находится Эхолот
    mode, roX, _, _, _, _, _ = sampTextdrawGetModelRotationZoomVehColor(echolot.slotTextDrawId)
    _, outlinecolo = sampTextdrawGetOutlineColor(echolot.slotTextDrawId)
    if mode == 18875 and roX == 263 and outlinecolo == 4284874850 then
        sampSendClickTextdraw(echolot.slotTextDrawId)
        wait(inventoryWait)
        sampSendClickTextdraw(2302)
    else -- если был перемещен - инициализируем заново
        toChat(errorEcholotClickFail)
        echolot.pageTextDrawId = -1
        echolot.slotTextDrawId = -1
        if not echolot.init() then
            return false
        end
        sampSendClickTextdraw(echolot.slotTextDrawId)
        wait(inventoryWait)
        sampSendClickTextdraw(2302)
    end
    
    return true
    
end
-- поиск Эхолота в инвентаре
function echolot.findInInventory()
    for pageNum = 2107, 2110 do
        wait(inventoryWait)
        sampSendClickTextdraw(pageNum)
        wait(inventoryWait)
        for id = 2142, 2207 do
            if sampTextdrawIsExists(id) then
                mode, roX, _, _, _, _, _ = sampTextdrawGetModelRotationZoomVehColor(id)
                _, outlinecolo = sampTextdrawGetOutlineColor(id)

                if mode == 18875 and roX == 263 and outlinecolo == 4284874850 then
                    echolot.pageTextDrawId = pageNum
                    echolot.slotTextDrawId = id
                    return true
                end
            end
        end
    end
    
    return false
end
-- инициализация Эхолота
function echolot.init()
    wait(inventoryWait)
    sampSendChat("/invent")
    wait(inventoryWait)
    -- если Эхолот найден в инвентаре - возвращаем true
    if not echolot.findInInventory() then
        toChat(errorEcholotEnitFail)
        return false
    end
    return true
end
-- использование Эхолота
function echolot.use()
    -- если Эхолот не инициализирован
    if echolot.pageTextDrawId == -1 or echolot.slotTextDrawId == -1 then
        toChat(echolotInintMessage)
        if not echolot.init() then
            return false
        else  -- если инициализация прошла успешно - кликаем на него
            toChat(echolotInintMessageSuccess)
            -- если удалось кликнуть на Эхолот
            if echolot.click() then
                return true
            end
        end
    else -- если уже был инициализирован - кликаем на него
        sampSendChat("/invent")
        wait(inventoryWait*2)
        -- если удалось кликнуть на Эхолот
        if echolot.click() then
            return true
        end
    end
    return false
end
 

KyRDa

Активный
107
67
Возможно ли добавлять на карту свои иконки?
89041C95A1B3CB4B7C7E284139CBD85DB44B117C
 
D

deleted-user-139653

Гость
Возможно ли добавлять на карту свои иконки?
89041C95A1B3CB4B7C7E284139CBD85DB44B117C
вот тебе пример
Lua:
local coordinates = {
{x = 2464, y = -1715, z = 13},
{x = 2020, y = -1203, z = 20},
{x = 2243, y = -1370, z = 40},
{x = 2832, y = -1208, z = 24},
{x = 2202, y = -2307, z = 14},
{x = 2504, y = -2641, z = 13},
{x = 2209, y = -2586, z = 15},
{x = 1653, y = -2553, z = 17},
{x = 1773, y = -1958, z = 19},
{x = 1723, y = -1615, z = 14},
{x = 2164, y = -1676, z = 18},
{x = 2217, y = -1151, z = 26},
{x = 1450, y = -1017, z = 25},
{x = 560, y = -1812, z = 6},
{x = 357, y = -2029, z = 10},
{x = 170, y = -1952, z = 3},
{x = 422, y = -1520, z = 31},
{x = 953, y = -1749, z = 13},
{x = 671, y = -1277, z = 18},
{x = 1294, y = -834, z = 83},
{x = 1951, y = -1366, z = 24},
{x = 1528, y = -1349, z = 329},
{x = 548, y = -1069, z = 76},
{x = 291, y = -1387, z = 13},
{x = -78, y = -1582, z = 5},
{x = -289, y = -2166, z = 31},
{x = -20, y = -2470, z = 36},
{x = 20, y = -2650, z = 45},
{x = -1568, y = -2732, z = 51},
{x = -2158, y = -2446, z = 33},
{x = -2402, y = -1633, z = 521},
{x = -2271, y = -1731, z = 487},
{x = -1955, y = -2441, z = 32},
{x = -1893, y = -1698, z = 24},
{x = 903, y = -1492, z = 13},
{x = -557, y = -1092, z = 23},
{x = -622, y = -470, z = 25},
{x = -1062, y = -563, z = 32},
{x = -531, y = -168, z = 81},
{x = -92, y = -405, z = 1},
{x = -109, y = -1174, z = 2},
{x = 1213, y = 224, z = 22},
{x = 1927, y = 169, z = 40},
{x = 2263, y = -79, z = 26},
{x = 2847, y = 944, z = 12},
{x = 2693, y = 825, z = 12},
{x = 2335, y = 987, z = 10},
{x = 2192, y = 923, z = 11},
{x = 812, y = 860, z = 15},
{x = 1552, y = 788, z = 11},
{x = 1669, y = 971, z = 11},
{x = 1854, y = 693, z = 11},
{x = 2579, y = 1062, z = 11},
{x = 2819, y = 1307, z = 10},
{x = 2473, y = 1544, z = 10},
{x = 2621, y = 1827, z = 13},
{x = 2402, y = 1883, z = 10},
{x = 2920, y = 2103, z = 21},
{x = 2821, y = 2359, z = 11},
{x = 2545, y = 2796, z = 10},
{x = 2327, y = 2427, z = 11},
{x = 2616, y = 2206, z = 13},
{x = 2098, y = 2368, z = 60},
{x = 2136, y = 2037, z = 10},
{x = 1999, y = 1539, z = 13},
{x = 2098, y = 1294, z = 10},
{x = 1325, y = 1537, z = 10},
{x = 1129, y = 1386, z = 10},
{x = 1034, y = 2063, z = 14},
{x = 1628, y = 1856, z = 10},
{x = 1621, y = 2210, z = 15},
{x = 1493, y = 2778, z = 10},
{x = -41, y = 17, z = 3},
{x = -323, y = 844, z = 18},
{x = -181, y = 1211, z = 21},
{x = -810, y = 1467, z = 19},
{x = -1050, y = 1563, z = 36},
{x = -1370, y = 2055, z = 55},
{x = -1480, y = 2646, z = 58},
{x = -1665, y = 2556, z = 88},
{x = -2376, y = 2434, z = 9},
{x = -2605, y = 1407, z = 7},
{x = -1817, y = 1399, z = 7},
{x = -1872, y = 1088, z = 47},
{x = -2070, y = 650, z = 52},
{x = -2400, y = 948, z = 47},
{x = -2615, y = 676, z = 28},
{x = -2837, y = 854, z = 44},
{x = -2378, y = 42, z = 35},
{x = -2156, y = -84, z = 35},
{x = -2138, y = -247, z = 36},
{x = -1990, y = 320, z = 35},
{x = -1527, y = 108, z = 19},
{x = -1458, y = -431, z = 6},
{x = -1361, y = -180, z = 6},
{x = -1227, y = 49, z = 14},
{x = -1437, y = -1447, z = 105},
{x = -1104, y = -1640, z = 79},
{x = 1357, y = -1663, z = 17},
{x = 1953, y = -1742, z = 18},
{x = 1656, y = -2553, z = 17},
}

local blips = {}
local isBlipCreated = {}

function main()
    repeat wait(0) until isSampAvailable()

    sampRegisterChatCommand("fp", function()
        on = not on
        sampAddChatMessage("{FFFFFF}FindPumpkin: " .. (on and "{00FF00}ON" or "{FF0000}OFF"))
        if not on then
            for i, blip in pairs(blips) do
                removeBlip(blip)
            end
            blips = {}
            isBlipCreated = {}
        end
    end)

    while true do wait(0)
        if on then
            x, y, z = getCharCoordinates(PLAYER_PED)
            for i, markerCoords in ipairs(coordinates) do
                local distance = getDistanceBetweenCoords3d(markerCoords.x, markerCoords.y, markerCoords.z, x, y, z)
           
                if distance < 500 and not isBlipCreated[i] then
                    local blip = addSpriteBlipForCoord(markerCoords.x, markerCoords.y, markerCoords.z, 41)
                    blips[i] = blip
                    isBlipCreated[i] = true
                elseif distance > 500 and isBlipCreated[i] then
                    if blips[i] then
                        removeBlip(blips[i])
                        blips[i] = nil
                    end
                    isBlipCreated[i] = false
                end
            end
        end
    end
end
image.png
 

T.Barrett

Новичок
27
0

g7HRwmi.png

Это замечательно, однако функционал этого плагина возвращает не тот указатель. Возможно я им не так пользуюсь?
 

KyRDa

Активный
107
67
вот тебе пример
Lua:
local coordinates = {
{x = 2464, y = -1715, z = 13},
{x = 2020, y = -1203, z = 20},
{x = 2243, y = -1370, z = 40},
{x = 2832, y = -1208, z = 24},
{x = 2202, y = -2307, z = 14},
{x = 2504, y = -2641, z = 13},
{x = 2209, y = -2586, z = 15},
{x = 1653, y = -2553, z = 17},
{x = 1773, y = -1958, z = 19},
{x = 1723, y = -1615, z = 14},
{x = 2164, y = -1676, z = 18},
{x = 2217, y = -1151, z = 26},
{x = 1450, y = -1017, z = 25},
{x = 560, y = -1812, z = 6},
{x = 357, y = -2029, z = 10},
{x = 170, y = -1952, z = 3},
{x = 422, y = -1520, z = 31},
{x = 953, y = -1749, z = 13},
{x = 671, y = -1277, z = 18},
{x = 1294, y = -834, z = 83},
{x = 1951, y = -1366, z = 24},
{x = 1528, y = -1349, z = 329},
{x = 548, y = -1069, z = 76},
{x = 291, y = -1387, z = 13},
{x = -78, y = -1582, z = 5},
{x = -289, y = -2166, z = 31},
{x = -20, y = -2470, z = 36},
{x = 20, y = -2650, z = 45},
{x = -1568, y = -2732, z = 51},
{x = -2158, y = -2446, z = 33},
{x = -2402, y = -1633, z = 521},
{x = -2271, y = -1731, z = 487},
{x = -1955, y = -2441, z = 32},
{x = -1893, y = -1698, z = 24},
{x = 903, y = -1492, z = 13},
{x = -557, y = -1092, z = 23},
{x = -622, y = -470, z = 25},
{x = -1062, y = -563, z = 32},
{x = -531, y = -168, z = 81},
{x = -92, y = -405, z = 1},
{x = -109, y = -1174, z = 2},
{x = 1213, y = 224, z = 22},
{x = 1927, y = 169, z = 40},
{x = 2263, y = -79, z = 26},
{x = 2847, y = 944, z = 12},
{x = 2693, y = 825, z = 12},
{x = 2335, y = 987, z = 10},
{x = 2192, y = 923, z = 11},
{x = 812, y = 860, z = 15},
{x = 1552, y = 788, z = 11},
{x = 1669, y = 971, z = 11},
{x = 1854, y = 693, z = 11},
{x = 2579, y = 1062, z = 11},
{x = 2819, y = 1307, z = 10},
{x = 2473, y = 1544, z = 10},
{x = 2621, y = 1827, z = 13},
{x = 2402, y = 1883, z = 10},
{x = 2920, y = 2103, z = 21},
{x = 2821, y = 2359, z = 11},
{x = 2545, y = 2796, z = 10},
{x = 2327, y = 2427, z = 11},
{x = 2616, y = 2206, z = 13},
{x = 2098, y = 2368, z = 60},
{x = 2136, y = 2037, z = 10},
{x = 1999, y = 1539, z = 13},
{x = 2098, y = 1294, z = 10},
{x = 1325, y = 1537, z = 10},
{x = 1129, y = 1386, z = 10},
{x = 1034, y = 2063, z = 14},
{x = 1628, y = 1856, z = 10},
{x = 1621, y = 2210, z = 15},
{x = 1493, y = 2778, z = 10},
{x = -41, y = 17, z = 3},
{x = -323, y = 844, z = 18},
{x = -181, y = 1211, z = 21},
{x = -810, y = 1467, z = 19},
{x = -1050, y = 1563, z = 36},
{x = -1370, y = 2055, z = 55},
{x = -1480, y = 2646, z = 58},
{x = -1665, y = 2556, z = 88},
{x = -2376, y = 2434, z = 9},
{x = -2605, y = 1407, z = 7},
{x = -1817, y = 1399, z = 7},
{x = -1872, y = 1088, z = 47},
{x = -2070, y = 650, z = 52},
{x = -2400, y = 948, z = 47},
{x = -2615, y = 676, z = 28},
{x = -2837, y = 854, z = 44},
{x = -2378, y = 42, z = 35},
{x = -2156, y = -84, z = 35},
{x = -2138, y = -247, z = 36},
{x = -1990, y = 320, z = 35},
{x = -1527, y = 108, z = 19},
{x = -1458, y = -431, z = 6},
{x = -1361, y = -180, z = 6},
{x = -1227, y = 49, z = 14},
{x = -1437, y = -1447, z = 105},
{x = -1104, y = -1640, z = 79},
{x = 1357, y = -1663, z = 17},
{x = 1953, y = -1742, z = 18},
{x = 1656, y = -2553, z = 17},
}

local blips = {}
local isBlipCreated = {}

function main()
    repeat wait(0) until isSampAvailable()

    sampRegisterChatCommand("fp", function()
        on = not on
        sampAddChatMessage("{FFFFFF}FindPumpkin: " .. (on and "{00FF00}ON" or "{FF0000}OFF"))
        if not on then
            for i, blip in pairs(blips) do
                removeBlip(blip)
            end
            blips = {}
            isBlipCreated = {}
        end
    end)

    while true do wait(0)
        if on then
            x, y, z = getCharCoordinates(PLAYER_PED)
            for i, markerCoords in ipairs(coordinates) do
                local distance = getDistanceBetweenCoords3d(markerCoords.x, markerCoords.y, markerCoords.z, x, y, z)
         
                if distance < 500 and not isBlipCreated[i] then
                    local blip = addSpriteBlipForCoord(markerCoords.x, markerCoords.y, markerCoords.z, 41)
                    blips[i] = blip
                    isBlipCreated[i] = true
                elseif distance > 500 and isBlipCreated[i] then
                    if blips[i] then
                        removeBlip(blips[i])
                        blips[i] = nil
                    end
                    isBlipCreated[i] = false
                end
            end
        end
    end
end
image.png
Возможно я не правильно задал вопрос. Это не то, что мне нужно
Я бы хотел брать иконки из отдельного файла и рисовать их на этой карте

1705006332963.png
 
Последнее редактирование:

lalalalalagg

Известный
5
4
qq, нужна помощь.

Lua:
imgui.InputText('##1', text_buffer)
imgui.SameLine()
if imgui.Button(u8'Добавить', imgui.ImVec2(70, 25)) and text_buffer.v ~= nil and text_buffer.v ~= '' then
    if current == 1 then
        table.insert(lvl1, text_buffer.v)
    end
end
if current == 1 then
    for k, v in ipairs(lvl1) do
        imgui.Text(k.. '. ' ..v)
        imgui.SameLine()
        if imgui.Button('-', imgui.ImVec2(20, 20)) then
            table.remove(lvl1)
        end
    end
end

В чем беда, рядом с добавленным текстом должна появляться кнопка в виде " - " и по её нажатию строка стоящая рядом должна удаляться, как исправить?
Щас оно удаляет только последнюю строку и только при нажатии на первую кнопку.
 
Последнее редактирование:

Andrinall

Известный
701
520
Это замечательно, однако функционал этого плагина возвращает не тот указатель. Возможно я им не так пользуюсь?
Возможно. С документацией ознакомился?
Lua:
local mad = require 'MoonAdditions'
function main()
    repeat wait(100) until isSampAvailable()
    sampRegisterChatCommand('/get', function()
        if not isPlayerPlaying(PLAYER_HANDLE) then return end
        if not isCharInAnyCar(PLAYER_PED) then return end

        local car = storeCarCharIsInNoSave(PLAYER_PED)
        local car_pointer = getCarPointer(car)
        local components = mad.get_all_vehicle_components(car)

        for i, comp in ipairs(components) do
            local comp_pointer = comp:get_pointer()
            print(i, comp.name, ("0x%X + 0x%X"):format(car_pointer, comp_pointer - car_pointer))
            if comp.name == 'wheel_rf_dummy' then comp:set_visibility(false) end
        end
    end)
    wait(-1)
1705037449801.png
1705037426409.png
[/screens]
 
Последнее редактирование:

chapo

tg/inst: @moujeek
Всефорумный модератор
9,127
12,254
qq, нужна помощь.

Lua:
imgui.InputText('##1', text_buffer)
imgui.SameLine()
if imgui.Button(u8'Добавить', imgui.ImVec2(70, 25)) and text_buffer.v ~= nil and text_buffer.v ~= '' then
    if current == 1 then
        table.insert(lvl1, text_buffer.v)
    end
end
if current == 1 then
    for k, v in ipairs(lvl1) do
        imgui.Text(k.. '. ' ..v)
        imgui.SameLine()
        if imgui.Button('-', imgui.ImVec2(20, 20)) then
            table.remove(lvl1)
        end
    end
end

В чем беда, рядом с добавленным текстом должна появляться кнопка в виде " - " и по её нажатию строка стоящая рядом должна удаляться, как исправить?
Щас оно удаляет только последнюю строку и только при нажатии на первую кнопку.
измени текст кнопки удаления с '-' на '-##' .. k и в table.remove в качестве второго аргумента укажи k
 
  • Влюблен
Реакции: lalalalalagg

DiteD331

Участник
99
13
Как оцените сложность Lua в плане кодинга? С какими трудностями может встретиться человек при его изучении? За какой промежуток времени можно освоить его? Легче ли Lua, чем Python? Рекомендуете к освоению LUA? Поделитесь своим опытом.
 
Последнее редактирование: