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

#SameLine

Активный
417
37
можешь попробовать рисовать текст через дравлист (хз есть ли там огран на кол-во символов)
Lua:
imgui.GetWindowDrawList():AddTextFontPtr(nil, 14, imgui.GetCursorScreenPos(), 0xFFffffff, 'твой текст', nil, 300) -- 300 - кол-во символов в строке (или пикселей, тут не уверен)
если не лень можешь попробовать решить эту тему https://www.blast.hk/threads/54986/, там походу чел пытался сделать из imgui wrapped TextUnformatted, мне нужно чтобы в себя брал он и много символов и отступы сам делал как imgui wrapped
 

why ega

РП игрок
Модератор
2,548
2,241
есть функция с задержкой в цикле, т.е. для нее нужен поток, дело в том, что это функция вызывается в каллбеке samp.events и как мне сделать так, чтобы при каждом вызове не было такого, что одна и таже функция работает одновременно, только в разных потоках?
Lua:
function sampev.onSendPlayerSync(data)       
   foo() -- работает параллельно несколько функций
end

function foo()   
    lua_thread.create(function()       
        -- code               
        while actived do       
           -- code
            wait(0)                             
        end       
    end)     
end
 
  • Грустно
Реакции: qdIbp

The Spark

Известный
653
672
есть функция с задержкой в цикле, т.е. для нее нужен поток, дело в том, что это функция вызывается в каллбеке samp.events и как мне сделать так, чтобы при каждом вызове не было такого, что одна и таже функция работает одновременно, только в разных потоках?
Lua:
function sampev.onSendPlayerSync(data)      
   foo() -- работает параллельно несколько функций
end

function foo()  
    lua_thread.create(function()      
        -- code              
        while actived do      
           -- code
            wait(0)                            
        end      
    end)    
end

Если я правльно тебя понял, то тебе нужно сохранять поток
Lua:
local thread = lua_thread.create_suspended(foo)

function sampev.onSendPlayerSync(data)
    local status = lua_thread:status()
    if status ~= "running" then
           thread:run(data)
    end
end

function foo(data)
    -- code               
    while actived do       
        -- code
        wait(0)                             
    end           
end
Ну а вообще, такой необходимости у тебя не должно было возникнуть, ты точно делаешь что-то не так.
Расскажи что именно ты хочешь сделать, если не устраивает ответ
 
  • Вау
Реакции: why ega

sosnov

Известный
331
115
хелпаните с мунботом,он на сервер зайти не может...
типо подключается и сразу отключается,вот фул коде:
Lua:
local mb = require('MoonBot')
local ev = require('lib.samp.events')
local imgui = require('mimgui')
local ffi = require ('ffi')
local ev = require('lib.samp.events')
local encoding = require('encoding')
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new, str, sizeof = imgui.new, ffi.string, ffi.sizeof
local inputField = new.char[256]()
local sizeX, sizeY = getScreenResolution()

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    imgui.Theme()
end)

local renderWindow = new.bool(),  new.bool()

local password = '123123'
local dist = 10
local raznos = false

local botData = {}
local presets = {}

local botName = new.char[256]()
local inputPreset = new.char(256)

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(220,200), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(600, 300), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Меню Бота-Пса", renderWindow,  imgui.WindowFlags.NoResize)
        if imgui.CollapsingHeader(u8' Управление Пёсиками') then
        imgui.Text(u8"Регистрация Пса")
        if imgui.InputText(u8"Введите кличку нового Пса##botName", botName, sizeof(botName)) then             
            text = u8:decode(ffi.string(botName))
        end           
        if imgui.Button(u8'Добавить Пса') then
            sampProcessChatInput(string.format('/pes.add %s', ffi.string(botName)))
        end
            imgui.Text(u8'Ваши собаки') imgui.NextColumn()
            for k, lBot in pairs(botData) do
                local bot = mb.getBotHandleByIndex(lBot.index)
                imgui.Separator()
                imgui.Text(string.format('%s[%d]', bot.name, bot.index)) imgui.NextColumn()
                imgui.Text(bot.connected and u8'Подключен' or u8'Не подключен') imgui.NextColumn()
                if imgui.Button(u8'Удалить') then
                    sampProcessChatInput('/pes.remove ' .. bot.index)
                end
            end
        end
        if imgui.CollapsingHeader(u8'Гавкалка') then
        imgui.Text(u8"Используйте: (Индекс пса) и (то что он прогавкает)")
        imgui.Text(u8"Пишите без скобок!")
        if imgui.InputText(u8"Введите то что гавкнет Пёс##botName", botName, sizeof(botName)) then             
            text = u8:decode(ffi.string(botName))
        end
        if imgui.Button(u8'Пёс! Гавкай!') then
            sampProcessChatInput(string.format('/gav %s', ffi.string(botName)))
        end
        end

        imgui.End()
    end
)

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[Pes Bot] {FFFFFF}Скрипт успешно загружен", -1)
    sampAddChatMessage("{FF0000}[Pes Bot] {FFFFFF}Автор : sosnov", -1)
    sampRegisterChatCommand('pesm', function() renderWindow[0] = not renderWindow[0] end) -- по команде
    --mb.disconnectAfterUnload(false)
    mb.registerIncomingRPC(61) -- dialog
    mb.registerIncomingRPC(68) -- spawnInfo
    mb.registerIncomingRPC(134) -- textdraw
    sampRegisterChatCommand('gav', function(param)
    if param ~= nil then
        for k, lBot in pairs(botData) do
            if param[1] == '/' then
                mb.getBotHandleByIndex(lBot.index):sendCommand(param)
            else
                mb.getBotHandleByIndex(lBot.index):sendChat(param)
            end
        end
    else
        sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Используй: /gav [msg]')
    end
    if param:match('%d+ .+') then
        local index, msg = param:match('(%d+) (.+)')
        index = tonumber(index)
        local found = false
        for k, lBot in pairs(botData) do
            if lBot.index == index then
                if msg[1] == '/' then
                    mb.getBotHandleByIndex(lBot.index):sendCommand(msg)
                else
                    mb.getBotHandleByIndex(lBot.index):sendChat(msg)
                end
                found = true
                break
            end
        end
        if not found then
            sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Не нашли Пса с таким индексом')
        end
    else
        sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Используй: {A7A7A7}/gav [Index] [msg]')
    end
end)
    sampRegisterChatCommand('pes.add', function(param)
        if param:len() >= 3 then
            local bot = mb.add(param)
            table.insert(botData, {
                index = bot.index,
                logined = false,
                rvanka = false,
                bot:sendRequestSpawn(0)
            })
            bot:connectAsNPC(true)
            bot:connect()
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF}Подключаем %s (Номер: %d)', bot.name, bot.index), -1)
        end
    end)
    sampRegisterChatCommand('pes.remove', function(param)
        if param:match('%d+') then
            local index = tonumber(param)
            for k, bot in pairs(mb.getBots()) do
                if bot.index == index then
                    sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF}Удалить %s (Номер: %d)', bot.name, bot.index), -1)
                    for j, lBot in pairs(botData) do
                        if lBot.index == bot.index then
                            table.remove(botData, j)
                            break
                        end
                    end
                    mb.remove(index)
                    break
                end
            end
        end
    end)
    sampRegisterChatCommand('fas', function()
        raznos = not raznos
        for k, lBot in pairs(botData) do
            local bot = mb.getBotHandleByIndex(lBot.index)
            if bot ~= nil then
                if not bot.connected and lBot.logined then
                    lBot.rvanka = false
                end
            end
        end
        sampAddChatMessage('raznos mode ' .. (raznos and 'ON' or 'OFF'), -1)
    end)
    while true do
        wait(50)   
        mb.updateCallbacks()
        local ped, playerId = nil, -1
        if raznos then
            local x, y, z = getCharCoordinates(PLAYER_PED)
            _, ped = findAllRandomCharsInSphere(x, y, z, 100, true, true)
            _, playerId = sampGetPlayerIdByCharHandle(ped)
            if _ and not sampIsPlayerPaused(playerId) and not sampIsPlayerNpc(playerId) then
                -- fine :3
            else
                ped = nil
            end
        end
        for k, lBot in pairs(botData) do
            local bot = mb.getBotHandleByIndex(lBot.index)
            if bot ~= nil then
                if not bot.connected and lBot.logined then
                    lBot.logined = false
                end
                if raznos then
                    if lBot.logined and ped ~= nil then
                        local angle = getCharHeading(ped)
                        local data = mb.getPlayerData()
                        local multiplier = 10
                        local x, y, z = getCharCoordinates(ped)
                        data.health = getCharHealth(PLAYER_PED)
                        data.armor = 0
                        data.weapon = 0
                        data.moveSpeed.x, data.moveSpeed.y, data.moveSpeed.z = math.sin(-math.rad(angle)) * multiplier, math.cos(-math.rad(angle)) * multiplier, multiplier
                        data.position.x, data.position.y, data.position.z = x - math.sin(-math.rad(angle)), y - math.cos(-math.rad(angle)), z + (isCharOnFoot(ped) and 0.5 or -1)
                        bot:sendPlayerData(data)
                        lBot.rvanka = true
                    else
                        lBot.rvanka = false
                    end
                else
                    lBot.rvanka = false
                end
            end
        end
        if ped ~= nil and raznos then
            printStringNow(string.format('Fisting for ~r~%s[%d]', sampGetPlayerNickname(playerId), playerId), 500)
        end
    end
end

function onBotIncomingPacket(bot, rpcId, bs)
    --sampfuncsLog(string.format('%s [%d] got packet: %d', bot.name, bot.index, packetId))
    if packetId == 41 then
        sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] успешно зашел (PlayerID: %d)', bot.name, bot.index, bot.playerID), -1)
    end
end

function onBotIncomingRPC(bot, rpcId, bs)
    if rpcId == 12 then
        for k, lBot in pairs(botData) do
        if lBot.index == bot.index then
            local x, y, z = bs:readFloat(), bs:readFloat(), bs:readFloat()
            lBot.position = {x = x, y = y, z = z}
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] {FFFFFF}сменил позицию {A7A7A7}(x: %d, y: %d, z: %d)', bot.name, bot.index, math.floor(x), math.floor(y), math.floor(z)))
            end
        end
    end
    --sampAddChatMessage('got rpc: ' .. rpcId, -1)
    if rpcId == 61 then
        local dialogId = bs:readInt16()
        local style = bs:readInt8()
        local title = bs:readString8()
        local btn1 = bs:readString8()
        local btn2 = bs:readString8()
        if title:find('Авторизация') then
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] загружается...', bot.name, bot.index), -1)
            bot:sendDialogResponse(dialogId, 1, 0, password)
        end
        if title:find('%(1/4%)') then
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] регистрируется...', bot.name, bot.index), -1)
            bot:sendDialogResponse(dialogId, 1, 0, password)
        end
        if title:find('%[2/5%]') or title:find('%[3/5%]') or title:find('%[3/4%]') then
            bot:sendDialogResponse(dialogId, 1, 0, '')
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] скипнул диалог (Заголовок: %s)', bot.name, bot.index, title), -1)
        end
    end
    if rpcId == 68 then
        for k, lBot in pairs(botData) do
            if lBot.index == bot.index and not lBot.logined then
                local team = bs:readInt8()
                local skin = bs:readInt32()
                local unk = bs:readInt8()
                local x, y, z = bs:readFloat(), bs:readFloat(), bs:readFloat()
                lBot.position = {x = x, y = y, z = z}
                lBot.logined = true
                bot:sendRequestSpawn()
                bot:sendSpawn()
                sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] заспавнился', bot.name, bot.index))
                break
            end
        end
    end
    if rpcId == 134 then
        local tdId = bs:readInt16()
        bs:ignoreBits(264)
        local x, y = bs:readFloat(), bs:readFloat()
        if x == 233.000000 and y == 367.000000 then
            for k, lBot in pairs(botData) do
                if lBot.index == bot.index then
                    local sync = mb.getPlayerData()
                    sync.position.x, sync.position.y, sync.position.z = lBot.position.x, lBot.position.y, lBot.position.z
                    sync.health = 100
                    sync.armor = 0
                    sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = 0, 0, 0, 0
                    sync.moveSpeed.x, sync.moveSpeed.y, sync.moveSpeed.z = 0, 0, 0
                    sync.weapon = 0
                    lBot.logined = false
                    bot:sendPlayerData(sync)
                    bot:sendClickTextdraw(tdId)
                    bot:sendRequestSpawn()
                    bot:sendSpawn()
                    addMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] выбрал скин', bot.name, bot.index))
                    break
                end
            end
        end
    end
end

function onScriptTerminate(script, quitGame)
    if script == thisScript() then
        mb.unload()
    end
end

function ev.onSendPlayerSync(data)
    local offset = 0
    for k, lBot in pairs(botData) do
        if lBot.logined and lBot ~= nil and not lBot.rvanka then
            offset = offset + 1
            local angle = getCharHeading(PLAYER_PED) - 90
            local sync = mb.getPlayerData()
            sync.position.x, sync.position.y, sync.position.z = data.position.x + math.sin(-math.rad(angle)) * offset, data.position.y + math.cos(-math.rad(angle)) * offset, data.position.z
            sync.health = data.health
            sync.armor = 0
            sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = data.quaternion[0], data.quaternion[1], data.quaternion[2], data.quaternion[3]
            sync.moveSpeed.x, sync.moveSpeed.y, sync.moveSpeed.z = data.moveSpeed.x, data.moveSpeed.y, data.moveSpeed.z
            sync.weapon = 0
            local bot = mb.getBotHandleByIndex(lBot.index)
            bot:sendPlayerData(sync)
        end
    end
end

function imgui.Theme()
    imgui.SwitchContext()
    imgui.GetStyle().FramePadding = imgui.ImVec2(3.5, 3.5)
    imgui.GetStyle().FrameRounding = 3
    imgui.GetStyle().ChildRounding = 2
    imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    imgui.GetStyle().WindowRounding = 2
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(5.0, 4.0)
    imgui.GetStyle().ScrollbarSize = 13.0
    imgui.GetStyle().ScrollbarRounding = 0
    imgui.GetStyle().GrabMinSize = 8.0
    imgui.GetStyle().GrabRounding = 1.0
    imgui.GetStyle().WindowPadding = imgui.ImVec2(4.0, 4.0)
    imgui.GetStyle().ButtonTextAlign = imgui.ImVec2(0.0, 0.5)

    imgui.GetStyle().Colors[imgui.Col.WindowBg] = imgui.ImVec4(0.14, 0.12, 0.16, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ChildBg] = imgui.ImVec4(0.30, 0.20, 0.39, 0.00)
    imgui.GetStyle().Colors[imgui.Col.PopupBg] = imgui.ImVec4(0.05, 0.05, 0.10, 0.90)
    imgui.GetStyle().Colors[imgui.Col.Border] = imgui.ImVec4(0.89, 0.85, 0.92, 0.30)
    imgui.GetStyle().Colors[imgui.Col.BorderShadow] = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBg] = imgui.ImVec4(0.30, 0.20, 0.39, 1.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBgHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.68)
    imgui.GetStyle().Colors[imgui.Col.FrameBgActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TitleBg] = imgui.ImVec4(0.41, 0.19, 0.63, 0.45)
    imgui.GetStyle().Colors[imgui.Col.TitleBgCollapsed] = imgui.ImVec4(0.41, 0.19, 0.63, 0.35)
    imgui.GetStyle().Colors[imgui.Col.TitleBgActive] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.MenuBarBg] = imgui.ImVec4(0.30, 0.20, 0.39, 0.57)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarBg] = imgui.ImVec4(0.30, 0.20, 0.39, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrab] = imgui.ImVec4(0.41, 0.19, 0.63, 0.31)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.CheckMark] = imgui.ImVec4(0.56, 0.61, 1.00, 1.00)
    imgui.GetStyle().Colors[imgui.Col.SliderGrab] = imgui.ImVec4(0.41, 0.19, 0.63, 0.24)
    imgui.GetStyle().Colors[imgui.Col.SliderGrabActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.41, 0.19, 0.63, 0.44)
    imgui.GetStyle().Colors[imgui.Col.ButtonHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.86)
    imgui.GetStyle().Colors[imgui.Col.ButtonActive] = imgui.ImVec4(0.64, 0.33, 0.94, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Header] = imgui.ImVec4(0.41, 0.19, 0.63, 0.76)
    imgui.GetStyle().Colors[imgui.Col.HeaderHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.86)
    imgui.GetStyle().Colors[imgui.Col.HeaderActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ResizeGrip] = imgui.ImVec4(0.41, 0.19, 0.63, 0.20)
    imgui.GetStyle().Colors[imgui.Col.ResizeGripHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.ResizeGripActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.PlotLines] = imgui.ImVec4(0.89, 0.85, 0.92, 0.63)
    imgui.GetStyle().Colors[imgui.Col.PlotLinesHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.PlotHistogram] = imgui.ImVec4(0.89, 0.85, 0.92, 0.63)
    imgui.GetStyle().Colors[imgui.Col.PlotHistogramHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TextSelectedBg] = imgui.ImVec4(0.41, 0.19, 0.63, 0.43)
end
 

Sadow

Известный
1,439
588
хелпаните с мунботом,он на сервер зайти не может...
типо подключается и сразу отключается,вот фул коде:
Lua:
local mb = require('MoonBot')
local ev = require('lib.samp.events')
local imgui = require('mimgui')
local ffi = require ('ffi')
local ev = require('lib.samp.events')
local encoding = require('encoding')
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new, str, sizeof = imgui.new, ffi.string, ffi.sizeof
local inputField = new.char[256]()
local sizeX, sizeY = getScreenResolution()

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    imgui.Theme()
end)

local renderWindow = new.bool(),  new.bool()

local password = '123123'
local dist = 10
local raznos = false

local botData = {}
local presets = {}

local botName = new.char[256]()
local inputPreset = new.char(256)

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(220,200), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(600, 300), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Меню Бота-Пса", renderWindow,  imgui.WindowFlags.NoResize)
        if imgui.CollapsingHeader(u8' Управление Пёсиками') then
        imgui.Text(u8"Регистрация Пса")
        if imgui.InputText(u8"Введите кличку нового Пса##botName", botName, sizeof(botName)) then            
            text = u8:decode(ffi.string(botName))
        end          
        if imgui.Button(u8'Добавить Пса') then
            sampProcessChatInput(string.format('/pes.add %s', ffi.string(botName)))
        end
            imgui.Text(u8'Ваши собаки') imgui.NextColumn()
            for k, lBot in pairs(botData) do
                local bot = mb.getBotHandleByIndex(lBot.index)
                imgui.Separator()
                imgui.Text(string.format('%s[%d]', bot.name, bot.index)) imgui.NextColumn()
                imgui.Text(bot.connected and u8'Подключен' or u8'Не подключен') imgui.NextColumn()
                if imgui.Button(u8'Удалить') then
                    sampProcessChatInput('/pes.remove ' .. bot.index)
                end
            end
        end
        if imgui.CollapsingHeader(u8'Гавкалка') then
        imgui.Text(u8"Используйте: (Индекс пса) и (то что он прогавкает)")
        imgui.Text(u8"Пишите без скобок!")
        if imgui.InputText(u8"Введите то что гавкнет Пёс##botName", botName, sizeof(botName)) then            
            text = u8:decode(ffi.string(botName))
        end
        if imgui.Button(u8'Пёс! Гавкай!') then
            sampProcessChatInput(string.format('/gav %s', ffi.string(botName)))
        end
        end

        imgui.End()
    end
)

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[Pes Bot] {FFFFFF}Скрипт успешно загружен", -1)
    sampAddChatMessage("{FF0000}[Pes Bot] {FFFFFF}Автор : sosnov", -1)
    sampRegisterChatCommand('pesm', function() renderWindow[0] = not renderWindow[0] end) -- по команде
    --mb.disconnectAfterUnload(false)
    mb.registerIncomingRPC(61) -- dialog
    mb.registerIncomingRPC(68) -- spawnInfo
    mb.registerIncomingRPC(134) -- textdraw
    sampRegisterChatCommand('gav', function(param)
    if param ~= nil then
        for k, lBot in pairs(botData) do
            if param[1] == '/' then
                mb.getBotHandleByIndex(lBot.index):sendCommand(param)
            else
                mb.getBotHandleByIndex(lBot.index):sendChat(param)
            end
        end
    else
        sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Используй: /gav [msg]')
    end
    if param:match('%d+ .+') then
        local index, msg = param:match('(%d+) (.+)')
        index = tonumber(index)
        local found = false
        for k, lBot in pairs(botData) do
            if lBot.index == index then
                if msg[1] == '/' then
                    mb.getBotHandleByIndex(lBot.index):sendCommand(msg)
                else
                    mb.getBotHandleByIndex(lBot.index):sendChat(msg)
                end
                found = true
                break
            end
        end
        if not found then
            sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Не нашли Пса с таким индексом')
        end
    else
        sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Используй: {A7A7A7}/gav [Index] [msg]')
    end
end)
    sampRegisterChatCommand('pes.add', function(param)
        if param:len() >= 3 then
            local bot = mb.add(param)
            table.insert(botData, {
                index = bot.index,
                logined = false,
                rvanka = false,
                bot:sendRequestSpawn(0)
            })
            bot:connectAsNPC(true)
            bot:connect()
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF}Подключаем %s (Номер: %d)', bot.name, bot.index), -1)
        end
    end)
    sampRegisterChatCommand('pes.remove', function(param)
        if param:match('%d+') then
            local index = tonumber(param)
            for k, bot in pairs(mb.getBots()) do
                if bot.index == index then
                    sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF}Удалить %s (Номер: %d)', bot.name, bot.index), -1)
                    for j, lBot in pairs(botData) do
                        if lBot.index == bot.index then
                            table.remove(botData, j)
                            break
                        end
                    end
                    mb.remove(index)
                    break
                end
            end
        end
    end)
    sampRegisterChatCommand('fas', function()
        raznos = not raznos
        for k, lBot in pairs(botData) do
            local bot = mb.getBotHandleByIndex(lBot.index)
            if bot ~= nil then
                if not bot.connected and lBot.logined then
                    lBot.rvanka = false
                end
            end
        end
        sampAddChatMessage('raznos mode ' .. (raznos and 'ON' or 'OFF'), -1)
    end)
    while true do
        wait(50)  
        mb.updateCallbacks()
        local ped, playerId = nil, -1
        if raznos then
            local x, y, z = getCharCoordinates(PLAYER_PED)
            _, ped = findAllRandomCharsInSphere(x, y, z, 100, true, true)
            _, playerId = sampGetPlayerIdByCharHandle(ped)
            if _ and not sampIsPlayerPaused(playerId) and not sampIsPlayerNpc(playerId) then
                -- fine :3
            else
                ped = nil
            end
        end
        for k, lBot in pairs(botData) do
            local bot = mb.getBotHandleByIndex(lBot.index)
            if bot ~= nil then
                if not bot.connected and lBot.logined then
                    lBot.logined = false
                end
                if raznos then
                    if lBot.logined and ped ~= nil then
                        local angle = getCharHeading(ped)
                        local data = mb.getPlayerData()
                        local multiplier = 10
                        local x, y, z = getCharCoordinates(ped)
                        data.health = getCharHealth(PLAYER_PED)
                        data.armor = 0
                        data.weapon = 0
                        data.moveSpeed.x, data.moveSpeed.y, data.moveSpeed.z = math.sin(-math.rad(angle)) * multiplier, math.cos(-math.rad(angle)) * multiplier, multiplier
                        data.position.x, data.position.y, data.position.z = x - math.sin(-math.rad(angle)), y - math.cos(-math.rad(angle)), z + (isCharOnFoot(ped) and 0.5 or -1)
                        bot:sendPlayerData(data)
                        lBot.rvanka = true
                    else
                        lBot.rvanka = false
                    end
                else
                    lBot.rvanka = false
                end
            end
        end
        if ped ~= nil and raznos then
            printStringNow(string.format('Fisting for ~r~%s[%d]', sampGetPlayerNickname(playerId), playerId), 500)
        end
    end
end

function onBotIncomingPacket(bot, rpcId, bs)
    --sampfuncsLog(string.format('%s [%d] got packet: %d', bot.name, bot.index, packetId))
    if packetId == 41 then
        sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] успешно зашел (PlayerID: %d)', bot.name, bot.index, bot.playerID), -1)
    end
end

function onBotIncomingRPC(bot, rpcId, bs)
    if rpcId == 12 then
        for k, lBot in pairs(botData) do
        if lBot.index == bot.index then
            local x, y, z = bs:readFloat(), bs:readFloat(), bs:readFloat()
            lBot.position = {x = x, y = y, z = z}
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] {FFFFFF}сменил позицию {A7A7A7}(x: %d, y: %d, z: %d)', bot.name, bot.index, math.floor(x), math.floor(y), math.floor(z)))
            end
        end
    end
    --sampAddChatMessage('got rpc: ' .. rpcId, -1)
    if rpcId == 61 then
        local dialogId = bs:readInt16()
        local style = bs:readInt8()
        local title = bs:readString8()
        local btn1 = bs:readString8()
        local btn2 = bs:readString8()
        if title:find('Авторизация') then
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] загружается...', bot.name, bot.index), -1)
            bot:sendDialogResponse(dialogId, 1, 0, password)
        end
        if title:find('%(1/4%)') then
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] регистрируется...', bot.name, bot.index), -1)
            bot:sendDialogResponse(dialogId, 1, 0, password)
        end
        if title:find('%[2/5%]') or title:find('%[3/5%]') or title:find('%[3/4%]') then
            bot:sendDialogResponse(dialogId, 1, 0, '')
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] скипнул диалог (Заголовок: %s)', bot.name, bot.index, title), -1)
        end
    end
    if rpcId == 68 then
        for k, lBot in pairs(botData) do
            if lBot.index == bot.index and not lBot.logined then
                local team = bs:readInt8()
                local skin = bs:readInt32()
                local unk = bs:readInt8()
                local x, y, z = bs:readFloat(), bs:readFloat(), bs:readFloat()
                lBot.position = {x = x, y = y, z = z}
                lBot.logined = true
                bot:sendRequestSpawn()
                bot:sendSpawn()
                sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] заспавнился', bot.name, bot.index))
                break
            end
        end
    end
    if rpcId == 134 then
        local tdId = bs:readInt16()
        bs:ignoreBits(264)
        local x, y = bs:readFloat(), bs:readFloat()
        if x == 233.000000 and y == 367.000000 then
            for k, lBot in pairs(botData) do
                if lBot.index == bot.index then
                    local sync = mb.getPlayerData()
                    sync.position.x, sync.position.y, sync.position.z = lBot.position.x, lBot.position.y, lBot.position.z
                    sync.health = 100
                    sync.armor = 0
                    sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = 0, 0, 0, 0
                    sync.moveSpeed.x, sync.moveSpeed.y, sync.moveSpeed.z = 0, 0, 0
                    sync.weapon = 0
                    lBot.logined = false
                    bot:sendPlayerData(sync)
                    bot:sendClickTextdraw(tdId)
                    bot:sendRequestSpawn()
                    bot:sendSpawn()
                    addMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] выбрал скин', bot.name, bot.index))
                    break
                end
            end
        end
    end
end

function onScriptTerminate(script, quitGame)
    if script == thisScript() then
        mb.unload()
    end
end

function ev.onSendPlayerSync(data)
    local offset = 0
    for k, lBot in pairs(botData) do
        if lBot.logined and lBot ~= nil and not lBot.rvanka then
            offset = offset + 1
            local angle = getCharHeading(PLAYER_PED) - 90
            local sync = mb.getPlayerData()
            sync.position.x, sync.position.y, sync.position.z = data.position.x + math.sin(-math.rad(angle)) * offset, data.position.y + math.cos(-math.rad(angle)) * offset, data.position.z
            sync.health = data.health
            sync.armor = 0
            sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = data.quaternion[0], data.quaternion[1], data.quaternion[2], data.quaternion[3]
            sync.moveSpeed.x, sync.moveSpeed.y, sync.moveSpeed.z = data.moveSpeed.x, data.moveSpeed.y, data.moveSpeed.z
            sync.weapon = 0
            local bot = mb.getBotHandleByIndex(lBot.index)
            bot:sendPlayerData(sync)
        end
    end
end

function imgui.Theme()
    imgui.SwitchContext()
    imgui.GetStyle().FramePadding = imgui.ImVec2(3.5, 3.5)
    imgui.GetStyle().FrameRounding = 3
    imgui.GetStyle().ChildRounding = 2
    imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    imgui.GetStyle().WindowRounding = 2
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(5.0, 4.0)
    imgui.GetStyle().ScrollbarSize = 13.0
    imgui.GetStyle().ScrollbarRounding = 0
    imgui.GetStyle().GrabMinSize = 8.0
    imgui.GetStyle().GrabRounding = 1.0
    imgui.GetStyle().WindowPadding = imgui.ImVec2(4.0, 4.0)
    imgui.GetStyle().ButtonTextAlign = imgui.ImVec2(0.0, 0.5)

    imgui.GetStyle().Colors[imgui.Col.WindowBg] = imgui.ImVec4(0.14, 0.12, 0.16, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ChildBg] = imgui.ImVec4(0.30, 0.20, 0.39, 0.00)
    imgui.GetStyle().Colors[imgui.Col.PopupBg] = imgui.ImVec4(0.05, 0.05, 0.10, 0.90)
    imgui.GetStyle().Colors[imgui.Col.Border] = imgui.ImVec4(0.89, 0.85, 0.92, 0.30)
    imgui.GetStyle().Colors[imgui.Col.BorderShadow] = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBg] = imgui.ImVec4(0.30, 0.20, 0.39, 1.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBgHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.68)
    imgui.GetStyle().Colors[imgui.Col.FrameBgActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TitleBg] = imgui.ImVec4(0.41, 0.19, 0.63, 0.45)
    imgui.GetStyle().Colors[imgui.Col.TitleBgCollapsed] = imgui.ImVec4(0.41, 0.19, 0.63, 0.35)
    imgui.GetStyle().Colors[imgui.Col.TitleBgActive] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.MenuBarBg] = imgui.ImVec4(0.30, 0.20, 0.39, 0.57)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarBg] = imgui.ImVec4(0.30, 0.20, 0.39, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrab] = imgui.ImVec4(0.41, 0.19, 0.63, 0.31)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.CheckMark] = imgui.ImVec4(0.56, 0.61, 1.00, 1.00)
    imgui.GetStyle().Colors[imgui.Col.SliderGrab] = imgui.ImVec4(0.41, 0.19, 0.63, 0.24)
    imgui.GetStyle().Colors[imgui.Col.SliderGrabActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.41, 0.19, 0.63, 0.44)
    imgui.GetStyle().Colors[imgui.Col.ButtonHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.86)
    imgui.GetStyle().Colors[imgui.Col.ButtonActive] = imgui.ImVec4(0.64, 0.33, 0.94, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Header] = imgui.ImVec4(0.41, 0.19, 0.63, 0.76)
    imgui.GetStyle().Colors[imgui.Col.HeaderHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.86)
    imgui.GetStyle().Colors[imgui.Col.HeaderActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ResizeGrip] = imgui.ImVec4(0.41, 0.19, 0.63, 0.20)
    imgui.GetStyle().Colors[imgui.Col.ResizeGripHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.ResizeGripActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.PlotLines] = imgui.ImVec4(0.89, 0.85, 0.92, 0.63)
    imgui.GetStyle().Colors[imgui.Col.PlotLinesHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.PlotHistogram] = imgui.ImVec4(0.89, 0.85, 0.92, 0.63)
    imgui.GetStyle().Colors[imgui.Col.PlotHistogramHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TextSelectedBg] = imgui.ImVec4(0.41, 0.19, 0.63, 0.43)
end
Lua:
local mb = require('MoonBot')
local ev = require('lib.samp.events')
local imgui = require('mimgui')
local ffi = require ('ffi')
local ev = require('lib.samp.events')
local encoding = require('encoding')
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new, str, sizeof = imgui.new, ffi.string, ffi.sizeof
local inputField = new.char[256]()
local sizeX, sizeY = getScreenResolution()

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    imgui.Theme()
end)

local renderWindow = new.bool(),  new.bool()

local password = '123123'
local dist = 10
local raznos = false

local botData = {}
local presets = {}

local botName = new.char[256]()
local inputPreset = new.char(256)

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(220,200), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(600, 300), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Меню Бота-Пса", renderWindow,  imgui.WindowFlags.NoResize)
        if imgui.CollapsingHeader(u8' Управление Пёсиками') then
        imgui.Text(u8"Регистрация Пса")
        if imgui.InputText(u8"Введите кличку нового Пса##botName", botName, sizeof(botName)) then             
            text = u8:decode(ffi.string(botName))
        end           
        if imgui.Button(u8'Добавить Пса') then
            sampProcessChatInput(string.format('/pes.add %s', ffi.string(botName)))
        end
            imgui.Text(u8'Ваши собаки') imgui.NextColumn()
            for k, lBot in pairs(botData) do
                local bot = mb.getBotHandleByIndex(lBot.index)
                imgui.Separator()
                imgui.Text(string.format('%s[%d]', bot.name, bot.index)) imgui.NextColumn()
                imgui.Text(bot.connected and u8'Подключен' or u8'Не подключен') imgui.NextColumn()
                if imgui.Button(u8'Удалить') then
                    sampProcessChatInput('/pes.remove ' .. bot.index)
                end
            end
        end
        if imgui.CollapsingHeader(u8'Гавкалка') then
        imgui.Text(u8"Используйте: (Индекс пса) и (то что он прогавкает)")
        imgui.Text(u8"Пишите без скобок!")
        if imgui.InputText(u8"Введите то что гавкнет Пёс##botName", botName, sizeof(botName)) then             
            text = u8:decode(ffi.string(botName))
        end
        if imgui.Button(u8'Пёс! Гавкай!') then
            sampProcessChatInput(string.format('/gav %s', ffi.string(botName)))
        end
        end

        imgui.End()
    end
)

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[Pes Bot] {FFFFFF}Скрипт успешно загружен", -1)
    sampAddChatMessage("{FF0000}[Pes Bot] {FFFFFF}Автор : sosnov", -1)
    sampRegisterChatCommand('pesm', function() renderWindow[0] = not renderWindow[0] end) -- по команде
    --mb.disconnectAfterUnload(false)
    mb.registerIncomingRPC(61) -- dialog
    mb.registerIncomingRPC(68) -- spawnInfo
    mb.registerIncomingRPC(134) -- textdraw
    sampRegisterChatCommand('gav', function(param)
    if param ~= nil then
        for k, lBot in pairs(botData) do
            if param[1] == '/' then
                mb.getBotHandleByIndex(lBot.index):sendCommand(param)
            else
                mb.getBotHandleByIndex(lBot.index):sendChat(param)
            end
        end
    else
        sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Используй: /gav [msg]')
    end
    if param:match('%d+ .+') then
        local index, msg = param:match('(%d+) (.+)')
        index = tonumber(index)
        local found = false
        for k, lBot in pairs(botData) do
            if lBot.index == index then
                if msg[1] == '/' then
                    mb.getBotHandleByIndex(lBot.index):sendCommand(msg)
                else
                    mb.getBotHandleByIndex(lBot.index):sendChat(msg)
                end
                found = true
                break
            end
        end
        if not found then
            sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Не нашли Пса с таким индексом')
        end
    else
        sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Используй: {A7A7A7}/gav [Index] [msg]')
    end
end)
    sampRegisterChatCommand('pes.add', function(param)
        if param:len() >= 3 then
            local bot = mb.add(param)
            table.insert(botData, {
                index = bot.index,
                logined = false,
                rvanka = false,
                bot:sendRequestSpawn(0)
            })
            bot:connectAsNPC(true)
            bot:connect()
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF}Подключаем %s (Номер: %d)', bot.name, bot.index), -1)
        end
    end)
    sampRegisterChatCommand('pes.remove', function(param)
        if param:match('%d+') then
            local index = tonumber(param)
            for k, bot in pairs(mb.getBots()) do
                if bot.index == index then
                    sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF}Удалить %s (Номер: %d)', bot.name, bot.index), -1)
                    for j, lBot in pairs(botData) do
                        if lBot.index == bot.index then
                            table.remove(botData, j)
                            break
                        end
                    end
                    mb.remove(index)
                    break
                end
            end
        end
    end)
    sampRegisterChatCommand('fas', function()
        raznos = not raznos
        for k, lBot in pairs(botData) do
            local bot = mb.getBotHandleByIndex(lBot.index)
            if bot ~= nil then
                if not bot.connected and lBot.logined then
                    lBot.rvanka = false
                end
            end
        end
        sampAddChatMessage('raznos mode ' .. (raznos and 'ON' or 'OFF'), -1)
    end)
    while true do
        wait(50)   
        mb.updateCallbacks()
        local ped, playerId = nil, -1
        if raznos then
            local x, y, z = getCharCoordinates(PLAYER_PED)
            _, ped = findAllRandomCharsInSphere(x, y, z, 100, true, true)
            _, playerId = sampGetPlayerIdByCharHandle(ped)
            if _ and not sampIsPlayerPaused(playerId) and not sampIsPlayerNpc(playerId) then
                -- fine :3
            else
                ped = nil
            end
        end
        for k, lBot in pairs(botData) do
            local bot = mb.getBotHandleByIndex(lBot.index)
            if bot ~= nil then
                if not bot.connected and lBot.logined then
                    lBot.logined = false
                end
                if raznos then
                    if lBot.logined and ped ~= nil then
                        local angle = getCharHeading(ped)
                        local data = mb.getPlayerData()
                        local multiplier = 10
                        local x, y, z = getCharCoordinates(ped)
                        data.health = getCharHealth(PLAYER_PED)
                        data.armor = 0
                        data.weapon = 0
                        data.moveSpeed.x, data.moveSpeed.y, data.moveSpeed.z = math.sin(-math.rad(angle)) * multiplier, math.cos(-math.rad(angle)) * multiplier, multiplier
                        data.position.x, data.position.y, data.position.z = x - math.sin(-math.rad(angle)), y - math.cos(-math.rad(angle)), z + (isCharOnFoot(ped) and 0.5 or -1)
                        bot:sendPlayerData(data)
                        lBot.rvanka = true
                    else
                        lBot.rvanka = false
                    end
                else
                    lBot.rvanka = false
                end
            end
        end
        if ped ~= nil and raznos then
            printStringNow(string.format('Fisting for ~r~%s[%d]', sampGetPlayerNickname(playerId), playerId), 500)
        end
    end
end

function onBotIncomingPacket(bot, rpcId, bs)
    --sampfuncsLog(string.format('%s [%d] got packet: %d', bot.name, bot.index, packetId))
    if packetId == 41 then
        sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] успешно зашел (PlayerID: %d)', bot.name, bot.index, bot.playerID), -1)
    end
end

function onBotIncomingRPC(bot, rpcId, bs)
    if rpcId == 12 then
        for k, lBot in pairs(botData) do
        if lBot.index == bot.index then
            local x, y, z = bs:readFloat(), bs:readFloat(), bs:readFloat()
            lBot.position = {x = x, y = y, z = z}
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] {FFFFFF}сменил позицию {A7A7A7}(x: %d, y: %d, z: %d)', bot.name, bot.index, math.floor(x), math.floor(y), math.floor(z)))
            end
        end
    end
    --sampAddChatMessage('got rpc: ' .. rpcId, -1)
    if rpcId == 61 then
        local dialogId = bs:readInt16()
        local style = bs:readInt8()
        local title = bs:readString8()
        local btn1 = bs:readString8()
        local btn2 = bs:readString8()
        if title:find('Авторизация') then
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] загружается...', bot.name, bot.index), -1)
            bot:sendDialogResponse(dialogId, 1, 0, password)
        end
        if title:find('%(1/4%)') then
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] регистрируется...', bot.name, bot.index), -1)
            bot:sendDialogResponse(dialogId, 1, 0, password)
        end
        if title:find('%[2/5%]') or title:find('%[3/5%]') or title:find('%[3/4%]') then
            bot:sendDialogResponse(dialogId, 1, 0, '')
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] скипнул диалог (Заголовок: %s)', bot.name, bot.index, title), -1)
        end
    end
    if rpcId == 68 then
        for k, lBot in pairs(botData) do
            if lBot.index == bot.index and not lBot.logined then
                local team = bs:readInt8()
                local skin = bs:readInt32()
                local unk = bs:readInt8()
                local x, y, z = bs:readFloat(), bs:readFloat(), bs:readFloat()
                lBot.position = {x = x, y = y, z = z}
                lBot.logined = true
                bot:sendRequestSpawn()
                bot:sendSpawn()
                sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] заспавнился', bot.name, bot.index))
                break
            end
        end
    end
    if rpcId == 134 then
        local tdId = bs:readInt16()
        bs:ignoreBits(264)
        local x, y = bs:readFloat(), bs:readFloat()
        if x == 233.000000 and y == 367.000000 then
            for k, lBot in pairs(botData) do
                if lBot.index == bot.index then
                    local sync = mb.getPlayerData()
                    sync.position.x, sync.position.y, sync.position.z = lBot.position.x, lBot.position.y, lBot.position.z
                    sync.health = 100
                    sync.armor = 0
                    sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = 0, 0, 0, 0
                    sync.moveSpeed.x, sync.moveSpeed.y, sync.moveSpeed.z = 0, 0, 0
                    sync.weapon = 0
                    lBot.logined = false
                    bot:sendPlayerData(sync)
                    bot:sendClickTextdraw(tdId)
                    bot:sendRequestSpawn()
                    bot:sendSpawn()
                    addMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] выбрал скин', bot.name, bot.index))
                    break
                end
            end
        end
    end
end

function ev.onSendPlayerSync(data)
    local offset = 0
    for k, lBot in pairs(botData) do
        if lBot.logined and lBot ~= nil and not lBot.rvanka then
            offset = offset + 1
            local angle = getCharHeading(PLAYER_PED) - 90
            local sync = mb.getPlayerData()
            sync.position.x, sync.position.y, sync.position.z = data.position.x + math.sin(-math.rad(angle)) * offset, data.position.y + math.cos(-math.rad(angle)) * offset, data.position.z
            sync.health = data.health
            sync.armor = 0
            sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = data.quaternion[0], data.quaternion[1], data.quaternion[2], data.quaternion[3]
            sync.moveSpeed.x, sync.moveSpeed.y, sync.moveSpeed.z = data.moveSpeed.x, data.moveSpeed.y, data.moveSpeed.z
            sync.weapon = 0
            local bot = mb.getBotHandleByIndex(lBot.index)
            bot:sendPlayerData(sync)
        end
    end
end

function imgui.Theme()
    imgui.SwitchContext()
    imgui.GetStyle().FramePadding = imgui.ImVec2(3.5, 3.5)
    imgui.GetStyle().FrameRounding = 3
    imgui.GetStyle().ChildRounding = 2
    imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    imgui.GetStyle().WindowRounding = 2
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(5.0, 4.0)
    imgui.GetStyle().ScrollbarSize = 13.0
    imgui.GetStyle().ScrollbarRounding = 0
    imgui.GetStyle().GrabMinSize = 8.0
    imgui.GetStyle().GrabRounding = 1.0
    imgui.GetStyle().WindowPadding = imgui.ImVec2(4.0, 4.0)
    imgui.GetStyle().ButtonTextAlign = imgui.ImVec2(0.0, 0.5)

    imgui.GetStyle().Colors[imgui.Col.WindowBg] = imgui.ImVec4(0.14, 0.12, 0.16, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ChildBg] = imgui.ImVec4(0.30, 0.20, 0.39, 0.00)
    imgui.GetStyle().Colors[imgui.Col.PopupBg] = imgui.ImVec4(0.05, 0.05, 0.10, 0.90)
    imgui.GetStyle().Colors[imgui.Col.Border] = imgui.ImVec4(0.89, 0.85, 0.92, 0.30)
    imgui.GetStyle().Colors[imgui.Col.BorderShadow] = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBg] = imgui.ImVec4(0.30, 0.20, 0.39, 1.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBgHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.68)
    imgui.GetStyle().Colors[imgui.Col.FrameBgActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TitleBg] = imgui.ImVec4(0.41, 0.19, 0.63, 0.45)
    imgui.GetStyle().Colors[imgui.Col.TitleBgCollapsed] = imgui.ImVec4(0.41, 0.19, 0.63, 0.35)
    imgui.GetStyle().Colors[imgui.Col.TitleBgActive] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.MenuBarBg] = imgui.ImVec4(0.30, 0.20, 0.39, 0.57)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarBg] = imgui.ImVec4(0.30, 0.20, 0.39, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrab] = imgui.ImVec4(0.41, 0.19, 0.63, 0.31)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.CheckMark] = imgui.ImVec4(0.56, 0.61, 1.00, 1.00)
    imgui.GetStyle().Colors[imgui.Col.SliderGrab] = imgui.ImVec4(0.41, 0.19, 0.63, 0.24)
    imgui.GetStyle().Colors[imgui.Col.SliderGrabActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.41, 0.19, 0.63, 0.44)
    imgui.GetStyle().Colors[imgui.Col.ButtonHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.86)
    imgui.GetStyle().Colors[imgui.Col.ButtonActive] = imgui.ImVec4(0.64, 0.33, 0.94, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Header] = imgui.ImVec4(0.41, 0.19, 0.63, 0.76)
    imgui.GetStyle().Colors[imgui.Col.HeaderHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.86)
    imgui.GetStyle().Colors[imgui.Col.HeaderActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ResizeGrip] = imgui.ImVec4(0.41, 0.19, 0.63, 0.20)
    imgui.GetStyle().Colors[imgui.Col.ResizeGripHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.ResizeGripActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.PlotLines] = imgui.ImVec4(0.89, 0.85, 0.92, 0.63)
    imgui.GetStyle().Colors[imgui.Col.PlotLinesHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.PlotHistogram] = imgui.ImVec4(0.89, 0.85, 0.92, 0.63)
    imgui.GetStyle().Colors[imgui.Col.PlotHistogramHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TextSelectedBg] = imgui.ImVec4(0.41, 0.19, 0.63, 0.43)
end
 

sosnov

Известный
331
115
Lua:
local mb = require('MoonBot')
local ev = require('lib.samp.events')
local imgui = require('mimgui')
local ffi = require ('ffi')
local ev = require('lib.samp.events')
local encoding = require('encoding')
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new, str, sizeof = imgui.new, ffi.string, ffi.sizeof
local inputField = new.char[256]()
local sizeX, sizeY = getScreenResolution()

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    imgui.Theme()
end)

local renderWindow = new.bool(),  new.bool()

local password = '123123'
local dist = 10
local raznos = false

local botData = {}
local presets = {}

local botName = new.char[256]()
local inputPreset = new.char(256)

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(220,200), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(600, 300), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Меню Бота-Пса", renderWindow,  imgui.WindowFlags.NoResize)
        if imgui.CollapsingHeader(u8' Управление Пёсиками') then
        imgui.Text(u8"Регистрация Пса")
        if imgui.InputText(u8"Введите кличку нового Пса##botName", botName, sizeof(botName)) then            
            text = u8:decode(ffi.string(botName))
        end          
        if imgui.Button(u8'Добавить Пса') then
            sampProcessChatInput(string.format('/pes.add %s', ffi.string(botName)))
        end
            imgui.Text(u8'Ваши собаки') imgui.NextColumn()
            for k, lBot in pairs(botData) do
                local bot = mb.getBotHandleByIndex(lBot.index)
                imgui.Separator()
                imgui.Text(string.format('%s[%d]', bot.name, bot.index)) imgui.NextColumn()
                imgui.Text(bot.connected and u8'Подключен' or u8'Не подключен') imgui.NextColumn()
                if imgui.Button(u8'Удалить') then
                    sampProcessChatInput('/pes.remove ' .. bot.index)
                end
            end
        end
        if imgui.CollapsingHeader(u8'Гавкалка') then
        imgui.Text(u8"Используйте: (Индекс пса) и (то что он прогавкает)")
        imgui.Text(u8"Пишите без скобок!")
        if imgui.InputText(u8"Введите то что гавкнет Пёс##botName", botName, sizeof(botName)) then            
            text = u8:decode(ffi.string(botName))
        end
        if imgui.Button(u8'Пёс! Гавкай!') then
            sampProcessChatInput(string.format('/gav %s', ffi.string(botName)))
        end
        end

        imgui.End()
    end
)

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[Pes Bot] {FFFFFF}Скрипт успешно загружен", -1)
    sampAddChatMessage("{FF0000}[Pes Bot] {FFFFFF}Автор : sosnov", -1)
    sampRegisterChatCommand('pesm', function() renderWindow[0] = not renderWindow[0] end) -- по команде
    --mb.disconnectAfterUnload(false)
    mb.registerIncomingRPC(61) -- dialog
    mb.registerIncomingRPC(68) -- spawnInfo
    mb.registerIncomingRPC(134) -- textdraw
    sampRegisterChatCommand('gav', function(param)
    if param ~= nil then
        for k, lBot in pairs(botData) do
            if param[1] == '/' then
                mb.getBotHandleByIndex(lBot.index):sendCommand(param)
            else
                mb.getBotHandleByIndex(lBot.index):sendChat(param)
            end
        end
    else
        sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Используй: /gav [msg]')
    end
    if param:match('%d+ .+') then
        local index, msg = param:match('(%d+) (.+)')
        index = tonumber(index)
        local found = false
        for k, lBot in pairs(botData) do
            if lBot.index == index then
                if msg[1] == '/' then
                    mb.getBotHandleByIndex(lBot.index):sendCommand(msg)
                else
                    mb.getBotHandleByIndex(lBot.index):sendChat(msg)
                end
                found = true
                break
            end
        end
        if not found then
            sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Не нашли Пса с таким индексом')
        end
    else
        sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Используй: {A7A7A7}/gav [Index] [msg]')
    end
end)
    sampRegisterChatCommand('pes.add', function(param)
        if param:len() >= 3 then
            local bot = mb.add(param)
            table.insert(botData, {
                index = bot.index,
                logined = false,
                rvanka = false,
                bot:sendRequestSpawn(0)
            })
            bot:connectAsNPC(true)
            bot:connect()
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF}Подключаем %s (Номер: %d)', bot.name, bot.index), -1)
        end
    end)
    sampRegisterChatCommand('pes.remove', function(param)
        if param:match('%d+') then
            local index = tonumber(param)
            for k, bot in pairs(mb.getBots()) do
                if bot.index == index then
                    sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF}Удалить %s (Номер: %d)', bot.name, bot.index), -1)
                    for j, lBot in pairs(botData) do
                        if lBot.index == bot.index then
                            table.remove(botData, j)
                            break
                        end
                    end
                    mb.remove(index)
                    break
                end
            end
        end
    end)
    sampRegisterChatCommand('fas', function()
        raznos = not raznos
        for k, lBot in pairs(botData) do
            local bot = mb.getBotHandleByIndex(lBot.index)
            if bot ~= nil then
                if not bot.connected and lBot.logined then
                    lBot.rvanka = false
                end
            end
        end
        sampAddChatMessage('raznos mode ' .. (raznos and 'ON' or 'OFF'), -1)
    end)
    while true do
        wait(50)  
        mb.updateCallbacks()
        local ped, playerId = nil, -1
        if raznos then
            local x, y, z = getCharCoordinates(PLAYER_PED)
            _, ped = findAllRandomCharsInSphere(x, y, z, 100, true, true)
            _, playerId = sampGetPlayerIdByCharHandle(ped)
            if _ and not sampIsPlayerPaused(playerId) and not sampIsPlayerNpc(playerId) then
                -- fine :3
            else
                ped = nil
            end
        end
        for k, lBot in pairs(botData) do
            local bot = mb.getBotHandleByIndex(lBot.index)
            if bot ~= nil then
                if not bot.connected and lBot.logined then
                    lBot.logined = false
                end
                if raznos then
                    if lBot.logined and ped ~= nil then
                        local angle = getCharHeading(ped)
                        local data = mb.getPlayerData()
                        local multiplier = 10
                        local x, y, z = getCharCoordinates(ped)
                        data.health = getCharHealth(PLAYER_PED)
                        data.armor = 0
                        data.weapon = 0
                        data.moveSpeed.x, data.moveSpeed.y, data.moveSpeed.z = math.sin(-math.rad(angle)) * multiplier, math.cos(-math.rad(angle)) * multiplier, multiplier
                        data.position.x, data.position.y, data.position.z = x - math.sin(-math.rad(angle)), y - math.cos(-math.rad(angle)), z + (isCharOnFoot(ped) and 0.5 or -1)
                        bot:sendPlayerData(data)
                        lBot.rvanka = true
                    else
                        lBot.rvanka = false
                    end
                else
                    lBot.rvanka = false
                end
            end
        end
        if ped ~= nil and raznos then
            printStringNow(string.format('Fisting for ~r~%s[%d]', sampGetPlayerNickname(playerId), playerId), 500)
        end
    end
end

function onBotIncomingPacket(bot, rpcId, bs)
    --sampfuncsLog(string.format('%s [%d] got packet: %d', bot.name, bot.index, packetId))
    if packetId == 41 then
        sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] успешно зашел (PlayerID: %d)', bot.name, bot.index, bot.playerID), -1)
    end
end

function onBotIncomingRPC(bot, rpcId, bs)
    if rpcId == 12 then
        for k, lBot in pairs(botData) do
        if lBot.index == bot.index then
            local x, y, z = bs:readFloat(), bs:readFloat(), bs:readFloat()
            lBot.position = {x = x, y = y, z = z}
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] {FFFFFF}сменил позицию {A7A7A7}(x: %d, y: %d, z: %d)', bot.name, bot.index, math.floor(x), math.floor(y), math.floor(z)))
            end
        end
    end
    --sampAddChatMessage('got rpc: ' .. rpcId, -1)
    if rpcId == 61 then
        local dialogId = bs:readInt16()
        local style = bs:readInt8()
        local title = bs:readString8()
        local btn1 = bs:readString8()
        local btn2 = bs:readString8()
        if title:find('Авторизация') then
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] загружается...', bot.name, bot.index), -1)
            bot:sendDialogResponse(dialogId, 1, 0, password)
        end
        if title:find('%(1/4%)') then
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] регистрируется...', bot.name, bot.index), -1)
            bot:sendDialogResponse(dialogId, 1, 0, password)
        end
        if title:find('%[2/5%]') or title:find('%[3/5%]') or title:find('%[3/4%]') then
            bot:sendDialogResponse(dialogId, 1, 0, '')
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] скипнул диалог (Заголовок: %s)', bot.name, bot.index, title), -1)
        end
    end
    if rpcId == 68 then
        for k, lBot in pairs(botData) do
            if lBot.index == bot.index and not lBot.logined then
                local team = bs:readInt8()
                local skin = bs:readInt32()
                local unk = bs:readInt8()
                local x, y, z = bs:readFloat(), bs:readFloat(), bs:readFloat()
                lBot.position = {x = x, y = y, z = z}
                lBot.logined = true
                bot:sendRequestSpawn()
                bot:sendSpawn()
                sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] заспавнился', bot.name, bot.index))
                break
            end
        end
    end
    if rpcId == 134 then
        local tdId = bs:readInt16()
        bs:ignoreBits(264)
        local x, y = bs:readFloat(), bs:readFloat()
        if x == 233.000000 and y == 367.000000 then
            for k, lBot in pairs(botData) do
                if lBot.index == bot.index then
                    local sync = mb.getPlayerData()
                    sync.position.x, sync.position.y, sync.position.z = lBot.position.x, lBot.position.y, lBot.position.z
                    sync.health = 100
                    sync.armor = 0
                    sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = 0, 0, 0, 0
                    sync.moveSpeed.x, sync.moveSpeed.y, sync.moveSpeed.z = 0, 0, 0
                    sync.weapon = 0
                    lBot.logined = false
                    bot:sendPlayerData(sync)
                    bot:sendClickTextdraw(tdId)
                    bot:sendRequestSpawn()
                    bot:sendSpawn()
                    addMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] выбрал скин', bot.name, bot.index))
                    break
                end
            end
        end
    end
end

function ev.onSendPlayerSync(data)
    local offset = 0
    for k, lBot in pairs(botData) do
        if lBot.logined and lBot ~= nil and not lBot.rvanka then
            offset = offset + 1
            local angle = getCharHeading(PLAYER_PED) - 90
            local sync = mb.getPlayerData()
            sync.position.x, sync.position.y, sync.position.z = data.position.x + math.sin(-math.rad(angle)) * offset, data.position.y + math.cos(-math.rad(angle)) * offset, data.position.z
            sync.health = data.health
            sync.armor = 0
            sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = data.quaternion[0], data.quaternion[1], data.quaternion[2], data.quaternion[3]
            sync.moveSpeed.x, sync.moveSpeed.y, sync.moveSpeed.z = data.moveSpeed.x, data.moveSpeed.y, data.moveSpeed.z
            sync.weapon = 0
            local bot = mb.getBotHandleByIndex(lBot.index)
            bot:sendPlayerData(sync)
        end
    end
end

function imgui.Theme()
    imgui.SwitchContext()
    imgui.GetStyle().FramePadding = imgui.ImVec2(3.5, 3.5)
    imgui.GetStyle().FrameRounding = 3
    imgui.GetStyle().ChildRounding = 2
    imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    imgui.GetStyle().WindowRounding = 2
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(5.0, 4.0)
    imgui.GetStyle().ScrollbarSize = 13.0
    imgui.GetStyle().ScrollbarRounding = 0
    imgui.GetStyle().GrabMinSize = 8.0
    imgui.GetStyle().GrabRounding = 1.0
    imgui.GetStyle().WindowPadding = imgui.ImVec2(4.0, 4.0)
    imgui.GetStyle().ButtonTextAlign = imgui.ImVec2(0.0, 0.5)

    imgui.GetStyle().Colors[imgui.Col.WindowBg] = imgui.ImVec4(0.14, 0.12, 0.16, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ChildBg] = imgui.ImVec4(0.30, 0.20, 0.39, 0.00)
    imgui.GetStyle().Colors[imgui.Col.PopupBg] = imgui.ImVec4(0.05, 0.05, 0.10, 0.90)
    imgui.GetStyle().Colors[imgui.Col.Border] = imgui.ImVec4(0.89, 0.85, 0.92, 0.30)
    imgui.GetStyle().Colors[imgui.Col.BorderShadow] = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBg] = imgui.ImVec4(0.30, 0.20, 0.39, 1.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBgHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.68)
    imgui.GetStyle().Colors[imgui.Col.FrameBgActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TitleBg] = imgui.ImVec4(0.41, 0.19, 0.63, 0.45)
    imgui.GetStyle().Colors[imgui.Col.TitleBgCollapsed] = imgui.ImVec4(0.41, 0.19, 0.63, 0.35)
    imgui.GetStyle().Colors[imgui.Col.TitleBgActive] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.MenuBarBg] = imgui.ImVec4(0.30, 0.20, 0.39, 0.57)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarBg] = imgui.ImVec4(0.30, 0.20, 0.39, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrab] = imgui.ImVec4(0.41, 0.19, 0.63, 0.31)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.CheckMark] = imgui.ImVec4(0.56, 0.61, 1.00, 1.00)
    imgui.GetStyle().Colors[imgui.Col.SliderGrab] = imgui.ImVec4(0.41, 0.19, 0.63, 0.24)
    imgui.GetStyle().Colors[imgui.Col.SliderGrabActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.41, 0.19, 0.63, 0.44)
    imgui.GetStyle().Colors[imgui.Col.ButtonHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.86)
    imgui.GetStyle().Colors[imgui.Col.ButtonActive] = imgui.ImVec4(0.64, 0.33, 0.94, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Header] = imgui.ImVec4(0.41, 0.19, 0.63, 0.76)
    imgui.GetStyle().Colors[imgui.Col.HeaderHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.86)
    imgui.GetStyle().Colors[imgui.Col.HeaderActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ResizeGrip] = imgui.ImVec4(0.41, 0.19, 0.63, 0.20)
    imgui.GetStyle().Colors[imgui.Col.ResizeGripHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.ResizeGripActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.PlotLines] = imgui.ImVec4(0.89, 0.85, 0.92, 0.63)
    imgui.GetStyle().Colors[imgui.Col.PlotLinesHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.PlotHistogram] = imgui.ImVec4(0.89, 0.85, 0.92, 0.63)
    imgui.GetStyle().Colors[imgui.Col.PlotHistogramHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TextSelectedBg] = imgui.ImVec4(0.41, 0.19, 0.63, 0.43)
end
то же самое что в моём коде,та же фигня,зайти не может на серв
 

why ega

РП игрок
Модератор
2,548
2,241
Lua:
local mb = require('MoonBot')
local ev = require('lib.samp.events')
local imgui = require('mimgui')
local ffi = require ('ffi')
local ev = require('lib.samp.events')
local encoding = require('encoding')
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local new, str, sizeof = imgui.new, ffi.string, ffi.sizeof
local inputField = new.char[256]()
local sizeX, sizeY = getScreenResolution()

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    imgui.Theme()
end)

local renderWindow = new.bool(),  new.bool()

local password = '123123'
local dist = 10
local raznos = false

local botData = {}
local presets = {}

local botName = new.char[256]()
local inputPreset = new.char(256)

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(player)
        imgui.SetNextWindowPos(imgui.ImVec2(220,200), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(600, 300), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Меню Бота-Пса", renderWindow,  imgui.WindowFlags.NoResize)
        if imgui.CollapsingHeader(u8' Управление Пёсиками') then
        imgui.Text(u8"Регистрация Пса")
        if imgui.InputText(u8"Введите кличку нового Пса##botName", botName, sizeof(botName)) then            
            text = u8:decode(ffi.string(botName))
        end          
        if imgui.Button(u8'Добавить Пса') then
            sampProcessChatInput(string.format('/pes.add %s', ffi.string(botName)))
        end
            imgui.Text(u8'Ваши собаки') imgui.NextColumn()
            for k, lBot in pairs(botData) do
                local bot = mb.getBotHandleByIndex(lBot.index)
                imgui.Separator()
                imgui.Text(string.format('%s[%d]', bot.name, bot.index)) imgui.NextColumn()
                imgui.Text(bot.connected and u8'Подключен' or u8'Не подключен') imgui.NextColumn()
                if imgui.Button(u8'Удалить') then
                    sampProcessChatInput('/pes.remove ' .. bot.index)
                end
            end
        end
        if imgui.CollapsingHeader(u8'Гавкалка') then
        imgui.Text(u8"Используйте: (Индекс пса) и (то что он прогавкает)")
        imgui.Text(u8"Пишите без скобок!")
        if imgui.InputText(u8"Введите то что гавкнет Пёс##botName", botName, sizeof(botName)) then            
            text = u8:decode(ffi.string(botName))
        end
        if imgui.Button(u8'Пёс! Гавкай!') then
            sampProcessChatInput(string.format('/gav %s', ffi.string(botName)))
        end
        end

        imgui.End()
    end
)

function main()
    repeat wait(0) until isSampAvailable()
    sampAddChatMessage("{FF0000}[Pes Bot] {FFFFFF}Скрипт успешно загружен", -1)
    sampAddChatMessage("{FF0000}[Pes Bot] {FFFFFF}Автор : sosnov", -1)
    sampRegisterChatCommand('pesm', function() renderWindow[0] = not renderWindow[0] end) -- по команде
    --mb.disconnectAfterUnload(false)
    mb.registerIncomingRPC(61) -- dialog
    mb.registerIncomingRPC(68) -- spawnInfo
    mb.registerIncomingRPC(134) -- textdraw
    sampRegisterChatCommand('gav', function(param)
    if param ~= nil then
        for k, lBot in pairs(botData) do
            if param[1] == '/' then
                mb.getBotHandleByIndex(lBot.index):sendCommand(param)
            else
                mb.getBotHandleByIndex(lBot.index):sendChat(param)
            end
        end
    else
        sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Используй: /gav [msg]')
    end
    if param:match('%d+ .+') then
        local index, msg = param:match('(%d+) (.+)')
        index = tonumber(index)
        local found = false
        for k, lBot in pairs(botData) do
            if lBot.index == index then
                if msg[1] == '/' then
                    mb.getBotHandleByIndex(lBot.index):sendCommand(msg)
                else
                    mb.getBotHandleByIndex(lBot.index):sendChat(msg)
                end
                found = true
                break
            end
        end
        if not found then
            sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Не нашли Пса с таким индексом')
        end
    else
        sampAddChatMessage('{FF0000}[Pes Bot]{FFFFFF}Используй: {A7A7A7}/gav [Index] [msg]')
    end
end)
    sampRegisterChatCommand('pes.add', function(param)
        if param:len() >= 3 then
            local bot = mb.add(param)
            table.insert(botData, {
                index = bot.index,
                logined = false,
                rvanka = false,
                bot:sendRequestSpawn(0)
            })
            bot:connectAsNPC(true)
            bot:connect()
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF}Подключаем %s (Номер: %d)', bot.name, bot.index), -1)
        end
    end)
    sampRegisterChatCommand('pes.remove', function(param)
        if param:match('%d+') then
            local index = tonumber(param)
            for k, bot in pairs(mb.getBots()) do
                if bot.index == index then
                    sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF}Удалить %s (Номер: %d)', bot.name, bot.index), -1)
                    for j, lBot in pairs(botData) do
                        if lBot.index == bot.index then
                            table.remove(botData, j)
                            break
                        end
                    end
                    mb.remove(index)
                    break
                end
            end
        end
    end)
    sampRegisterChatCommand('fas', function()
        raznos = not raznos
        for k, lBot in pairs(botData) do
            local bot = mb.getBotHandleByIndex(lBot.index)
            if bot ~= nil then
                if not bot.connected and lBot.logined then
                    lBot.rvanka = false
                end
            end
        end
        sampAddChatMessage('raznos mode ' .. (raznos and 'ON' or 'OFF'), -1)
    end)
    while true do
        wait(50)  
        mb.updateCallbacks()
        local ped, playerId = nil, -1
        if raznos then
            local x, y, z = getCharCoordinates(PLAYER_PED)
            _, ped = findAllRandomCharsInSphere(x, y, z, 100, true, true)
            _, playerId = sampGetPlayerIdByCharHandle(ped)
            if _ and not sampIsPlayerPaused(playerId) and not sampIsPlayerNpc(playerId) then
                -- fine :3
            else
                ped = nil
            end
        end
        for k, lBot in pairs(botData) do
            local bot = mb.getBotHandleByIndex(lBot.index)
            if bot ~= nil then
                if not bot.connected and lBot.logined then
                    lBot.logined = false
                end
                if raznos then
                    if lBot.logined and ped ~= nil then
                        local angle = getCharHeading(ped)
                        local data = mb.getPlayerData()
                        local multiplier = 10
                        local x, y, z = getCharCoordinates(ped)
                        data.health = getCharHealth(PLAYER_PED)
                        data.armor = 0
                        data.weapon = 0
                        data.moveSpeed.x, data.moveSpeed.y, data.moveSpeed.z = math.sin(-math.rad(angle)) * multiplier, math.cos(-math.rad(angle)) * multiplier, multiplier
                        data.position.x, data.position.y, data.position.z = x - math.sin(-math.rad(angle)), y - math.cos(-math.rad(angle)), z + (isCharOnFoot(ped) and 0.5 or -1)
                        bot:sendPlayerData(data)
                        lBot.rvanka = true
                    else
                        lBot.rvanka = false
                    end
                else
                    lBot.rvanka = false
                end
            end
        end
        if ped ~= nil and raznos then
            printStringNow(string.format('Fisting for ~r~%s[%d]', sampGetPlayerNickname(playerId), playerId), 500)
        end
    end
end

function onBotIncomingPacket(bot, rpcId, bs)
    --sampfuncsLog(string.format('%s [%d] got packet: %d', bot.name, bot.index, packetId))
    if packetId == 41 then
        sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] успешно зашел (PlayerID: %d)', bot.name, bot.index, bot.playerID), -1)
    end
end

function onBotIncomingRPC(bot, rpcId, bs)
    if rpcId == 12 then
        for k, lBot in pairs(botData) do
        if lBot.index == bot.index then
            local x, y, z = bs:readFloat(), bs:readFloat(), bs:readFloat()
            lBot.position = {x = x, y = y, z = z}
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] {FFFFFF}сменил позицию {A7A7A7}(x: %d, y: %d, z: %d)', bot.name, bot.index, math.floor(x), math.floor(y), math.floor(z)))
            end
        end
    end
    --sampAddChatMessage('got rpc: ' .. rpcId, -1)
    if rpcId == 61 then
        local dialogId = bs:readInt16()
        local style = bs:readInt8()
        local title = bs:readString8()
        local btn1 = bs:readString8()
        local btn2 = bs:readString8()
        if title:find('Авторизация') then
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] загружается...', bot.name, bot.index), -1)
            bot:sendDialogResponse(dialogId, 1, 0, password)
        end
        if title:find('%(1/4%)') then
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] регистрируется...', bot.name, bot.index), -1)
            bot:sendDialogResponse(dialogId, 1, 0, password)
        end
        if title:find('%[2/5%]') or title:find('%[3/5%]') or title:find('%[3/4%]') then
            bot:sendDialogResponse(dialogId, 1, 0, '')
            sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s [%d] скипнул диалог (Заголовок: %s)', bot.name, bot.index, title), -1)
        end
    end
    if rpcId == 68 then
        for k, lBot in pairs(botData) do
            if lBot.index == bot.index and not lBot.logined then
                local team = bs:readInt8()
                local skin = bs:readInt32()
                local unk = bs:readInt8()
                local x, y, z = bs:readFloat(), bs:readFloat(), bs:readFloat()
                lBot.position = {x = x, y = y, z = z}
                lBot.logined = true
                bot:sendRequestSpawn()
                bot:sendSpawn()
                sampAddChatMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] заспавнился', bot.name, bot.index))
                break
            end
        end
    end
    if rpcId == 134 then
        local tdId = bs:readInt16()
        bs:ignoreBits(264)
        local x, y = bs:readFloat(), bs:readFloat()
        if x == 233.000000 and y == 367.000000 then
            for k, lBot in pairs(botData) do
                if lBot.index == bot.index then
                    local sync = mb.getPlayerData()
                    sync.position.x, sync.position.y, sync.position.z = lBot.position.x, lBot.position.y, lBot.position.z
                    sync.health = 100
                    sync.armor = 0
                    sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = 0, 0, 0, 0
                    sync.moveSpeed.x, sync.moveSpeed.y, sync.moveSpeed.z = 0, 0, 0
                    sync.weapon = 0
                    lBot.logined = false
                    bot:sendPlayerData(sync)
                    bot:sendClickTextdraw(tdId)
                    bot:sendRequestSpawn()
                    bot:sendSpawn()
                    addMessage(string.format('{FF0000}[Pes Bot]{FFFFFF} %s[%d] выбрал скин', bot.name, bot.index))
                    break
                end
            end
        end
    end
end

function ev.onSendPlayerSync(data)
    local offset = 0
    for k, lBot in pairs(botData) do
        if lBot.logined and lBot ~= nil and not lBot.rvanka then
            offset = offset + 1
            local angle = getCharHeading(PLAYER_PED) - 90
            local sync = mb.getPlayerData()
            sync.position.x, sync.position.y, sync.position.z = data.position.x + math.sin(-math.rad(angle)) * offset, data.position.y + math.cos(-math.rad(angle)) * offset, data.position.z
            sync.health = data.health
            sync.armor = 0
            sync.quaternion.w, sync.quaternion.x, sync.quaternion.y, sync.quaternion.z = data.quaternion[0], data.quaternion[1], data.quaternion[2], data.quaternion[3]
            sync.moveSpeed.x, sync.moveSpeed.y, sync.moveSpeed.z = data.moveSpeed.x, data.moveSpeed.y, data.moveSpeed.z
            sync.weapon = 0
            local bot = mb.getBotHandleByIndex(lBot.index)
            bot:sendPlayerData(sync)
        end
    end
end

function imgui.Theme()
    imgui.SwitchContext()
    imgui.GetStyle().FramePadding = imgui.ImVec2(3.5, 3.5)
    imgui.GetStyle().FrameRounding = 3
    imgui.GetStyle().ChildRounding = 2
    imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    imgui.GetStyle().WindowRounding = 2
    imgui.GetStyle().ItemSpacing = imgui.ImVec2(5.0, 4.0)
    imgui.GetStyle().ScrollbarSize = 13.0
    imgui.GetStyle().ScrollbarRounding = 0
    imgui.GetStyle().GrabMinSize = 8.0
    imgui.GetStyle().GrabRounding = 1.0
    imgui.GetStyle().WindowPadding = imgui.ImVec2(4.0, 4.0)
    imgui.GetStyle().ButtonTextAlign = imgui.ImVec2(0.0, 0.5)

    imgui.GetStyle().Colors[imgui.Col.WindowBg] = imgui.ImVec4(0.14, 0.12, 0.16, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ChildBg] = imgui.ImVec4(0.30, 0.20, 0.39, 0.00)
    imgui.GetStyle().Colors[imgui.Col.PopupBg] = imgui.ImVec4(0.05, 0.05, 0.10, 0.90)
    imgui.GetStyle().Colors[imgui.Col.Border] = imgui.ImVec4(0.89, 0.85, 0.92, 0.30)
    imgui.GetStyle().Colors[imgui.Col.BorderShadow] = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBg] = imgui.ImVec4(0.30, 0.20, 0.39, 1.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBgHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.68)
    imgui.GetStyle().Colors[imgui.Col.FrameBgActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TitleBg] = imgui.ImVec4(0.41, 0.19, 0.63, 0.45)
    imgui.GetStyle().Colors[imgui.Col.TitleBgCollapsed] = imgui.ImVec4(0.41, 0.19, 0.63, 0.35)
    imgui.GetStyle().Colors[imgui.Col.TitleBgActive] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.MenuBarBg] = imgui.ImVec4(0.30, 0.20, 0.39, 0.57)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarBg] = imgui.ImVec4(0.30, 0.20, 0.39, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrab] = imgui.ImVec4(0.41, 0.19, 0.63, 0.31)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.CheckMark] = imgui.ImVec4(0.56, 0.61, 1.00, 1.00)
    imgui.GetStyle().Colors[imgui.Col.SliderGrab] = imgui.ImVec4(0.41, 0.19, 0.63, 0.24)
    imgui.GetStyle().Colors[imgui.Col.SliderGrabActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Button] = imgui.ImVec4(0.41, 0.19, 0.63, 0.44)
    imgui.GetStyle().Colors[imgui.Col.ButtonHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.86)
    imgui.GetStyle().Colors[imgui.Col.ButtonActive] = imgui.ImVec4(0.64, 0.33, 0.94, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Header] = imgui.ImVec4(0.41, 0.19, 0.63, 0.76)
    imgui.GetStyle().Colors[imgui.Col.HeaderHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.86)
    imgui.GetStyle().Colors[imgui.Col.HeaderActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ResizeGrip] = imgui.ImVec4(0.41, 0.19, 0.63, 0.20)
    imgui.GetStyle().Colors[imgui.Col.ResizeGripHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 0.78)
    imgui.GetStyle().Colors[imgui.Col.ResizeGripActive] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.PlotLines] = imgui.ImVec4(0.89, 0.85, 0.92, 0.63)
    imgui.GetStyle().Colors[imgui.Col.PlotLinesHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.PlotHistogram] = imgui.ImVec4(0.89, 0.85, 0.92, 0.63)
    imgui.GetStyle().Colors[imgui.Col.PlotHistogramHovered] = imgui.ImVec4(0.41, 0.19, 0.63, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TextSelectedBg] = imgui.ImVec4(0.41, 0.19, 0.63, 0.43)
end
Попробуй в onbotincomingpacket добавить проверку на 34 пакет и если тотприходит, отправить bot:sendRequestClass(0)
 

why ega

РП игрок
Модератор
2,548
2,241
у меня там нет 34 пакета😮
только 134
кинь ссылку на 34
{34, bs = {{"ip", "Int32"}, {"port", "Int16"}, {"playerId", "UInt16"}, {"challenge", "Int32"}}, description = "Исходит от сервера, когда запрос клиента на соединение с сервером был принят.", name = "PACKET_CONNECTION_REQUEST_ACCEPTED"}
крч, при коннекте к серверу, ты отправишь нужный рпц
 
  • Нравится
Реакции: sosnov