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

E E E E E E E

Активный
154
28
[ML] (error) huy.lua: C:\Program Files (x86)\SAMP\moonloader\huy.lua:49: syntax error near 'end'
[ML] (error) huy.lua: Script died due to an error. (0E3BF1EC)

Lua:
    sampRegisterChatCommand("getplayers", function()
        for i = 0, 999 do
            if sampIsPlayerConnected(i) then
                local nick = sampGetPlayerNickname(i)
                local sampAddChatMessage(nick)
            end
        end
    end)

на sampAddChatMessage не обращайте внимание, это мунлоадер решил что так надо написать
 
Последнее редактирование:

nimaverniy

Новичок
5
2
Как создать типо бота админа, нужно что бы он реагировал на текст из чата, типо Nick_Nickovich(65): Тп на аб, и он сразу через комманду /gethere его телепортирует, новичек хз как
 

CaJlaT

07.11.2024 14:55
Модератор
2,857
2,721
[ML] (error) huy.lua: C:\Program Files (x86)\SAMP\moonloader\huy.lua:49: syntax error near 'end'
[ML] (error) huy.lua: Script died due to an error. (0E3BF1EC)

Lua:
    sampRegisterChatCommand("getplayers", function()
        for i = 0, 999 do
            if sampIsPlayerConnected(i) then
                local nick = sampGetPlayerNickname(i)
                local sampAddChatMessage(nick)
            end
        end
    end)

на sampAddChatMessage не обращайте внимание, это мунлоадер решил что так надо написать
Убери локал перед sampAddChatMessage
 

E E E E E E E

Активный
154
28
шо на хуетень сукаа
Lua:
function hook.onServerMessage(color, text)
        if chat.v then
            for i = 0, 999 do
                if sampIsPlayerConnected(i) then
                    local nick = sampGetPlayerNickname(i)
                    if text:find (nick) then
                        return {color, text, '[' .. i .. ']'}
                    end
                end
            end
        end
end

[ML] (error) huy.lua: C:\Program Files (x86)\SAMP\moonloader\huy.lua:207: attempt to index global 'chat' (a nil value)
stack traceback:
C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:207: in function 'callback'
...ram Files (x86)\SAMP\moonloader\lib\samp\events\core.lua:79: in function <...ram Files (x86)\SAMP\moonloader\lib\samp\events\core.lua:53>
[ML] (error) huy.lua: Script died due to an error. (0E5744AC)


скрипт вмэрае через 2 сек после включения этой функции
ало помогите пж
 

E E E E E E E

Активный
154
28
Так написал, как будто ты скинул эту строчку, но в коде, который ты скинул ее нет, может там у тебя опечатка в названии переменной
Lua:
script_author('E E E E E E E')

require 'lib.moonloader'
local hook = require 'lib.samp.events'
local imgui = require 'imgui'
local red = 0xF24B4B
imgui.ToggleButton = require('imgui_addons').ToggleButton
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

lua_thread.create(function()

local themes = import "resource/imgui_themes.lua"
local vkeys = require 'vkeys'

imgui.SwitchContext()
themes.SwitchColorTheme(2)

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local    anti_drop = imgui.ImBool(false)
local chat_id = imgui.ImBool(false)
local    sbiv = imgui.ImBool(false)
local    test = imgui.ImBool(false)
local    aptechka = imgui.ImBool(false)
local    speedcar = imgui.ImBool(false)
local    taxi = imgui.ImBool(false)
local    sbiv_piss = imgui.ImBool(false)
local    esc = imgui.ImBool(false)
local    radius_cmd = imgui.ImBool(false)

end)

function main()
    repeat wait(0) until isSampAvailable()
    printStringNow("~r~Evolve~w~ Helper ~g~ON", 1500)
    wait(1500)
    printString('~r~Evolve~w~ Helper: ~r~/e.menu', 1500)
    sampRegisterChatCommand("e.menu", function()
        main_window_state.v = not main_window_state.v
              imgui.Process = main_window_state.v
    end)
    sampRegisterChatCommand("getplayers", function()
        for i = 0, 999 do
            if sampIsPlayerConnected(i) then
                local nick = sampGetPlayerNickname(i)
                sampAddChatMessage(nick..'[' .. i ..']')
            end
        end
    end)

        imgui.Process = false

        while true do
            wait(0)

            if radius_cmd.v then
                for k,v in pairs(getAllChars()) do
                    x, y, z = getCharCoordinates(PLAYER_PED)
                    mX, mY, mZ = getCharCoordinates(v)
                     dist = getDistanceBetweenCoords3d(x, y, z, mX, mY, mZ)
                        if dist <= 5 then
                            idv = sampGetPlayerIdByCharHandle(v)
                            sampSendChat('/pseat'.. idv)
                        end
                end
            end

            if sbiv_piss.v then
                if not sampIsDialogActive() and not sampIsChatInputActive() then
                    if isKeyDown(VK_R) and isKeyJustPressed(VK_3) then
                        sampSendChat("/piss")
                    end
                end
            end

            if taxi.v then
                if not sampIsDialogActive() and not sampIsChatInputActive() then
                    if isKeyDown(VK_N) and isKeyJustPressed(VK_M) then
                        sampSendChat('От души брат)')
                        wait(1500)
                        sampSendChat('Удачи')
                        wait(1000)
                        sampSendChat(')')
                    end
                end
            end

            if speedcar.v then
                speed = getCharSpeed(PLAYER_PED)
                carspeed = tonumber(speed)
                    if isCharInAnyCar(PLAYER_PED) and carspeed >= 0 then
                        printString(math.floor(carspeed), 500)
                    end
            end

            if aptechka.v then
                if not sampIsDialogActive() and not sampIsChatInputActive() then
                    if isKeyDown(VK_R) and isKeyJustPressed(VK_2) then
                        sampSendChat("/usedrugs 15")
                    end
                end
            end

            if sbiv.v then
                _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
                        idanimation = sampGetPlayerAnimationId(id)
                            if idanimation == 1191 then
                                wait(1)
                                x, y, z = getCharCoordinates(PLAYER_PED)
                                zi = z -1
                                setCharCoordinates(PLAYER_PED, x, y, zi)
                            end
                        end
                    end
                end

    function imgui.OnDrawFrame()
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(577, 300), imgui.Cond.FirstUseEver)

        if not main_window_state.v then
            imgui.Process = false
        end

            imgui.Begin("Evolve Helper BETA 1.0.0 bY E E E E E E E", main_window_state, imgui.WindowFlags.NoResize)
            imgui.Text(u8"                           Работы:                                                        Транспорт:")
            imgui.BeginChild(u8"Работы", imgui.ImVec2(250, 100), true)
            imgui.ToggleButton('##anti_drop', anti_drop)
            imgui.SameLine()
            imgui.Text(u8'Анти дроп обьектов')
            imgui.SameLine()
            imgui.TextQuestion(u8'Вы не будете ронять мешок или другой любой обьект в руках. !WARNING!: Иногда может кикать!')
            imgui.ToggleButton('##sbiv', sbiv)
            imgui.SameLine()
            imgui.Text(u8'Авто сбив отдышки')
            imgui.SameLine()
            imgui.TextQuestion(u8'После удара у вашего персонажа не будет отдышки')
            imgui.ToggleButton('##sbiv_piss', sbiv_piss)
            imgui.SameLine()
            imgui.Text(u8'Сбив на /piss (шоб по гетто \nящерски выглядила)')
            imgui.SameLine()
            imgui.TextQuestion(u8'Активация: R + 3')
            imgui.EndChild()

            imgui.SameLine()
            imgui.BeginChild("Транспорт", imgui.ImVec2(313, 100), true)
            imgui.ToggleButton('##speedcar', speedcar)
            imgui.SameLine()
            imgui.Text(u8'Спидометр(для мопедов)')
            imgui.SameLine()
            imgui.TextQuestion(u8'Как мы знаем, на Evolve нету спидометра когда сидишь за мопедом, это функция исправляет это!')
            imgui.ToggleButton('##taxi', taxi)
            imgui.SameLine()
            imgui.Text(u8'Отблагодарить таксиста за поездку (N + M)')
            imgui.SameLine()
            imgui.TextQuestion(u8'хз зач я это добавил, а может. B релизе этой надписи и не будет:(...')
            imgui.EndChild()

            imgui.Text(u8"                           Разное:")
            imgui.BeginChild(u8"Разное", imgui.ImVec2(410, 100), true)
            imgui.ToggleButton('##chat_id', chat_id)
            imgui.SameLine()
            imgui.Text(u8'Ники игроков в чате[BETA]')
            imgui.SameLine()
            imgui.TextQuestion(u8'Не работает на Evolve, но на других работает(hackmysoftware)')
            imgui.ToggleButton('##aptechka', aptechka)
            imgui.SameLine()
            imgui.Text(u8'Автоматически принимает вещества, активация:  R + 2')
            imgui.SameLine()
            imgui.TextQuestion(u8'При нажатии R + 2 игрок автоматически введёт "/usedrugs 15"')
            imgui.ToggleButton('##esc', esc)
            imgui.SameLine()
            imgui.Text(u8'Игнор надписей по типу "Не флуди!"')
            imgui.SameLine()
            imgui.TextQuestion(u8'Рил кому то не ясно?')
            imgui.ToggleButton('##radius_cmd', radius_cmd)
            imgui.SameLine()
            imgui.Text(u8'ид игроков в радиусе')
            imgui.EndChild()

            imgui.SetCursorPosY(220)
            imgui.SetCursorPosX(440)
            imgui.Text(u8'Автор на BlastHack:')
            imgui.SetCursorPosY(239)
            imgui.SetCursorPosX(440)
            if imgui.Button('Copy url') then
                setClipboardText('https://www.blast.hk/members/495401/')
            end
            imgui.End()

        end


function imgui.TextQuestion(text)
  imgui.TextDisabled('(?)')
      if imgui.IsItemHovered() then
            imgui.BeginTooltip()
          imgui.PushTextWrapPos(450)
          imgui.TextUnformatted(text)
          imgui.PopTextWrapPos()
          imgui.EndTooltip()
      end
    end

function hook.onSendPlayerSync(data)
    if anti_drop.v then
        data.keysData = 0
    end
end



function onScriptTerminate(script, quitGame)
    if script == thisScript() then
        sampAddChatMessage("{F24B4B}[Evolve Helper]:{FFFFFF} Скрипт был {F24B4B}крашнут{FFFFFF}, нажмите {F24B4B}CNTRL{FFFFFF} + {F24B4B}R{FFFFFF} чтобы перезагрузить", -1)
        printStringNow("~r~Evolve ~w~Helper ~r~ OFF", 2500)
    end
end

function hook.onServerMessage(color, text)
        if chat_id.v then
            for i = 0, 999 do
                if sampIsPlayerConnected(i) then
                    local nick = sampGetPlayerNickname(i)
                    if text:find (nick) then
                        return {color, text..'[' ..i.. ']'}
                    end
                end
            end
        end
end

[ML] (error) EvolveHelper.lua: C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:224: attempt to index global 'chat_id' (a nil value)
stack traceback:
C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:224: in function 'callback'
...ram Files (x86)\SAMP\moonloader\lib\samp\events\core.lua:79: in function <...ram Files (x86)\SAMP\moonloader\lib\samp\events\core.lua:53>
[ML] (error) EvolveHelper.lua: Script died due to an error. (31B8C4DC) или
[ML] (error) EvolveHelper.lua: C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:58: attempt to index global 'radius_cmd' (a nil value)
stack traceback:
C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua: in function <C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:35>
[ML] (error) EvolveHelper.lua: Script died due to an error. (25BBDF5C)
[ML] (script) ML-AutoReboot: Loading "C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua"...
[ML] (system) Loading script 'C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua'...

Lua:
script_author('E E E E E E E')

require 'lib.moonloader'
local hook = require 'lib.samp.events'
local imgui = require 'imgui'
local red = 0xF24B4B
imgui.ToggleButton = require('imgui_addons').ToggleButton
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

lua_thread.create(function()

local themes = import "resource/imgui_themes.lua"
local vkeys = require 'vkeys'

imgui.SwitchContext()
themes.SwitchColorTheme(2)

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local    anti_drop = imgui.ImBool(false)
local chat_id = imgui.ImBool(false)
local    sbiv = imgui.ImBool(false)
local    test = imgui.ImBool(false)
local    aptechka = imgui.ImBool(false)
local    speedcar = imgui.ImBool(false)
local    taxi = imgui.ImBool(false)
local    sbiv_piss = imgui.ImBool(false)
local    esc = imgui.ImBool(false)
local    radius_cmd = imgui.ImBool(false)

end)

function main()
    repeat wait(0) until isSampAvailable()
    printStringNow("~r~Evolve~w~ Helper ~g~ON", 1500)
    wait(1500)
    printString('~r~Evolve~w~ Helper: ~r~/e.menu', 1500)
    sampRegisterChatCommand("e.menu", function()
        main_window_state.v = not main_window_state.v
              imgui.Process = main_window_state.v
    end)
    sampRegisterChatCommand("getplayers", function()
        for i = 0, 999 do
            if sampIsPlayerConnected(i) then
                local nick = sampGetPlayerNickname(i)
                sampAddChatMessage(nick..'[' .. i ..']')
            end
        end
    end)

        imgui.Process = false

        while true do
            wait(0)

            if radius_cmd.v then
                for k,v in pairs(getAllChars()) do
                    x, y, z = getCharCoordinates(PLAYER_PED)
                    mX, mY, mZ = getCharCoordinates(v)
                     dist = getDistanceBetweenCoords3d(x, y, z, mX, mY, mZ)
                        if dist <= 5 then
                            idv = sampGetPlayerIdByCharHandle(v)
                            sampSendChat('/pseat'.. idv)
                        end
                end
            end

            if sbiv_piss.v then
                if not sampIsDialogActive() and not sampIsChatInputActive() then
                    if isKeyDown(VK_R) and isKeyJustPressed(VK_3) then
                        sampSendChat("/piss")
                    end
                end
            end

            if taxi.v then
                if not sampIsDialogActive() and not sampIsChatInputActive() then
                    if isKeyDown(VK_N) and isKeyJustPressed(VK_M) then
                        sampSendChat('От души брат)')
                        wait(1500)
                        sampSendChat('Удачи')
                        wait(1000)
                        sampSendChat(')')
                    end
                end
            end

            if speedcar.v then
                speed = getCharSpeed(PLAYER_PED)
                carspeed = tonumber(speed)
                    if isCharInAnyCar(PLAYER_PED) and carspeed >= 0 then
                        printString(math.floor(carspeed), 500)
                    end
            end

            if aptechka.v then
                if not sampIsDialogActive() and not sampIsChatInputActive() then
                    if isKeyDown(VK_R) and isKeyJustPressed(VK_2) then
                        sampSendChat("/usedrugs 15")
                    end
                end
            end

            if sbiv.v then
                _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
                        idanimation = sampGetPlayerAnimationId(id)
                            if idanimation == 1191 then
                                wait(1)
                                x, y, z = getCharCoordinates(PLAYER_PED)
                                zi = z -1
                                setCharCoordinates(PLAYER_PED, x, y, zi)
                            end
                        end
                    end
                end

    function imgui.OnDrawFrame()
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(577, 300), imgui.Cond.FirstUseEver)

        if not main_window_state.v then
            imgui.Process = false
        end

            imgui.Begin("Evolve Helper BETA 1.0.0 bY E E E E E E E", main_window_state, imgui.WindowFlags.NoResize)
            imgui.Text(u8"                           Работы:                                                        Транспорт:")
            imgui.BeginChild(u8"Работы", imgui.ImVec2(250, 100), true)
            imgui.ToggleButton('##anti_drop', anti_drop)
            imgui.SameLine()
            imgui.Text(u8'Анти дроп обьектов')
            imgui.SameLine()
            imgui.TextQuestion(u8'Вы не будете ронять мешок или другой любой обьект в руках. !WARNING!: Иногда может кикать!')
            imgui.ToggleButton('##sbiv', sbiv)
            imgui.SameLine()
            imgui.Text(u8'Авто сбив отдышки')
            imgui.SameLine()
            imgui.TextQuestion(u8'После удара у вашего персонажа не будет отдышки')
            imgui.ToggleButton('##sbiv_piss', sbiv_piss)
            imgui.SameLine()
            imgui.Text(u8'Сбив на /piss (шоб по гетто \nящерски выглядила)')
            imgui.SameLine()
            imgui.TextQuestion(u8'Активация: R + 3')
            imgui.EndChild()

            imgui.SameLine()
            imgui.BeginChild("Транспорт", imgui.ImVec2(313, 100), true)
            imgui.ToggleButton('##speedcar', speedcar)
            imgui.SameLine()
            imgui.Text(u8'Спидометр(для мопедов)')
            imgui.SameLine()
            imgui.TextQuestion(u8'Как мы знаем, на Evolve нету спидометра когда сидишь за мопедом, это функция исправляет это!')
            imgui.ToggleButton('##taxi', taxi)
            imgui.SameLine()
            imgui.Text(u8'Отблагодарить таксиста за поездку (N + M)')
            imgui.SameLine()
            imgui.TextQuestion(u8'хз зач я это добавил, а может. B релизе этой надписи и не будет:(...')
            imgui.EndChild()

            imgui.Text(u8"                           Разное:")
            imgui.BeginChild(u8"Разное", imgui.ImVec2(410, 100), true)
            imgui.ToggleButton('##chat_id', chat_id)
            imgui.SameLine()
            imgui.Text(u8'Ники игроков в чате[BETA]')
            imgui.SameLine()
            imgui.TextQuestion(u8'Не работает на Evolve, но на других работает(hackmysoftware)')
            imgui.ToggleButton('##aptechka', aptechka)
            imgui.SameLine()
            imgui.Text(u8'Автоматически принимает вещества, активация:  R + 2')
            imgui.SameLine()
            imgui.TextQuestion(u8'При нажатии R + 2 игрок автоматически введёт "/usedrugs 15"')
            imgui.ToggleButton('##esc', esc)
            imgui.SameLine()
            imgui.Text(u8'Игнор надписей по типу "Не флуди!"')
            imgui.SameLine()
            imgui.TextQuestion(u8'Рил кому то не ясно?')
            imgui.ToggleButton('##radius_cmd', radius_cmd)
            imgui.SameLine()
            imgui.Text(u8'ид игроков в радиусе')
            imgui.EndChild()

            imgui.SetCursorPosY(220)
            imgui.SetCursorPosX(440)
            imgui.Text(u8'Автор на BlastHack:')
            imgui.SetCursorPosY(239)
            imgui.SetCursorPosX(440)
            if imgui.Button('Copy url') then
                setClipboardText('https://www.blast.hk/members/495401/')
            end
            imgui.End()

        end


function imgui.TextQuestion(text)
  imgui.TextDisabled('(?)')
      if imgui.IsItemHovered() then
            imgui.BeginTooltip()
          imgui.PushTextWrapPos(450)
          imgui.TextUnformatted(text)
          imgui.PopTextWrapPos()
          imgui.EndTooltip()
      end
    end

function hook.onSendPlayerSync(data)
    if anti_drop.v then
        data.keysData = 0
    end
end



function onScriptTerminate(script, quitGame)
    if script == thisScript() then
        sampAddChatMessage("{F24B4B}[Evolve Helper]:{FFFFFF} Скрипт был {F24B4B}крашнут{FFFFFF}, нажмите {F24B4B}CNTRL{FFFFFF} + {F24B4B}R{FFFFFF} чтобы перезагрузить", -1)
        printStringNow("~r~Evolve ~w~Helper ~r~ OFF", 2500)
    end
end

function hook.onServerMessage(color, text)
        if chat_id.v then
            for i = 0, 999 do
                if sampIsPlayerConnected(i) then
                    local nick = sampGetPlayerNickname(i)
                    if text:find (nick) then
                        return {color, text..'[' ..i.. ']'}
                    end
                end
            end
        end
end

[ML] (error) EvolveHelper.lua: C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:224: attempt to index global 'chat_id' (a nil value)
stack traceback:
C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:224: in function 'callback'
...ram Files (x86)\SAMP\moonloader\lib\samp\events\core.lua:79: in function <...ram Files (x86)\SAMP\moonloader\lib\samp\events\core.lua:53>
[ML] (error) EvolveHelper.lua: Script died due to an error. (31B8C4DC) или
[ML] (error) EvolveHelper.lua: C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:58: attempt to index global 'radius_cmd' (a nil value)
stack traceback:
C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua: in function <C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:35>
[ML] (error) EvolveHelper.lua: Script died due to an error. (25BBDF5C)
[ML] (script) ML-AutoReboot: Loading "C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua"...
[ML] (system) Loading script 'C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua'...
бля в атоме в начале нету таких пробелов огромни
 

вайега52

Налуашил состояние
Модератор
2,976
3,094
Как можно проверить запущен самп (не подключение к серверу, а именно инициализирован самп или не) без использования функций сф по типу
Lua:
bool = isSampfuncsLoaded()
bool = isSampAvailable()
под запущен я подразумеваю тот момент, когда на экране появляется чат и всякая подобная хрень
 

Shepi

Активный
178
37
Помогите пажалуста. Я нубик.
imgui.OnInitialize вызвал лишь один раз
скрипт крашит с такой ошибкой

[ML] (error) BebraSC: С:\сборки самп\sborOchka - копия\moonloader\lib\mimgui\init.lua:302: attempt to index upvalue 'renderer' (a nil value)
stack traceback:
С:\сборки самп\sborOchka - копия\moonloader\lib\mimgui\init.lua: in function 'SwitchContext'
C:\сборки самп\sborOchka - копия\moonloader\BebraSC.lua:343: in function 'theme'
C:\сборки самп\sborOchka - копия\moonloader\BebraSC.lua:30: in function <C:\сборки самп\sborOchka - копия\moonloader\BebraSC.lua:28>
[ML] (error) Bebrasc: Script died due to an error. (10682D8C)
функцию theme вызываю при инициализации скрипта.

а вот и функция theme

bebra:
function theme()
    imgui.SwitchContext()
    imgui.GetStyle().WindowRounding        = 7.0
    imgui.GetStyle().ChildRounding        = 7.0
    imgui.GetStyle().FrameRounding        = 10.0
    imgui.GetStyle().FramePadding        = imgui.ImVec2(5, 3)
    imgui.GetStyle().WindowPadding        = imgui.ImVec2(8, 8)
    imgui.GetStyle().ButtonTextAlign    = imgui.ImVec2(0.5, 0.5)
    imgui.GetStyle().GrabMinSize        = 7
    imgui.GetStyle().GrabRounding        = 15

    imgui.GetStyle().Colors[imgui.Col.Text]                    = imgui.ImVec4(1.00, 1.00, 1.00, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TextDisabled]            = imgui.ImVec4(1.00, 1.00, 1.00, 0.20)
    imgui.GetStyle().Colors[imgui.Col.WindowBg]                = imgui.ImVec4(0.07, 0.07, 0.09, 1.00)
    imgui.GetStyle().Colors[imgui.Col.PopupBg]                = imgui.ImVec4(0.90, 0.90, 0.90, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Border]                = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
    imgui.GetStyle().Colors[imgui.Col.SliderGrab]            = imgui.ImVec4(0.90, 0.90, 0.90, 1.00)
    imgui.GetStyle().Colors[imgui.Col.SliderGrabActive]        = imgui.ImVec4(0.70, 0.70, 0.70, 1.00)
    imgui.GetStyle().Colors[imgui.Col.BorderShadow]            = imgui.ImVec4(0.00, 0.00, 0.00, 0.00)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarBg]            = imgui.ImVec4(0.60, 0.60, 0.60, 0.90)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrab]        = imgui.ImVec4(0.90, 0.90, 0.90, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabHovered]    = imgui.ImVec4(0.80, 0.80, 0.80, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ScrollbarGrabActive]    = imgui.ImVec4(0.70, 0.70, 0.70, 1.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBg]                = imgui.ImVec4(0.20, 0.20, 0.20, 1.00)
    imgui.GetStyle().Colors[imgui.Col.FrameBgHovered]        = imgui.ImVec4(0.20, 0.20, 0.20, 0.80)
    imgui.GetStyle().Colors[imgui.Col.FrameBgActive]        = imgui.ImVec4(0.20, 0.20, 0.20, 0.60)
    imgui.GetStyle().Colors[imgui.Col.CheckMark]            = imgui.ImVec4(1.00, 1.00, 1.00, 1.00)
    imgui.GetStyle().Colors[imgui.Col.Button]                = imgui.ImVec4(0.20, 0.20, 0.20, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ButtonHovered]        = imgui.ImVec4(0.15, 0.15, 0.15, 1.00)
    imgui.GetStyle().Colors[imgui.Col.ButtonActive]            = imgui.ImVec4(0.10, 0.10, 0.10, 1.00)
    imgui.GetStyle().Colors[imgui.Col.TextSelectedBg]        = imgui.ImVec4(0.80, 0.80, 0.80, 0.80)

    local but_orig = imgui.Button
    imgui.Button = function(...)
        imgui.PushStyleColor(imgui.Col.Text, imgui.ImVec4(0.07, 0.07, 0.09, 1.00))
        imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0.90, 0.90, 0.90, 1.00))
        imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(0.80, 0.80, 0.80, 1.00))
        imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(0.70, 0.70, 0.70, 1.00))
        local result = but_orig(...)
        imgui.PopStyleColor(4)
        return result
    end
end
 

E E E E E E E

Активный
154
28
[ML] (error) EvolveHelper.lua: C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:41: attempt to index global 'main_window_state' (a nil value)
stack traceback:
C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:41: in function <C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:40>
[ML] (error) EvolveHelper.lua: Script died due to an error. (4003466C)
Lua:
script_author('E E E E E E E')

require 'lib.moonloader'
local hook = require 'lib.samp.events'
local imgui = require 'imgui'
local red = 0xF24B4B
imgui.ToggleButton = require('imgui_addons').ToggleButton
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

lua_thread.create(function()

local themes = import "resource/imgui_themes.lua"
local vkeys = require 'vkeys'

imgui.SwitchContext()
themes.SwitchColorTheme(2)

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local anti_drop = imgui.ImBool(false)
local chat_id = imgui.ImBool(false)
local sbiv = imgui.ImBool(false)
local test = imgui.ImBool(false)
local aptechka = imgui.ImBool(false)
local speedcar = imgui.ImBool(false)
local taxi = imgui.ImBool(false)
local sbiv_piss = imgui.ImBool(false)
local esc = imgui.ImBool(false)
local radius_cmd = imgui.ImBool(false)

end)

function main()
    repeat wait(0) until isSampAvailable()
    printStringNow("~r~Evolve~w~ Helper ~g~ON", 1500)
    wait(1500)
    printString('~r~Evolve~w~ Helper: ~r~/e.menu', 1500)
    sampRegisterChatCommand("e.menu", function()
        main_window_state.v = not main_window_state.v
                imgui.Process = main_window_state.v
    end)
    
    sampRegisterChatCommand("getplayers", function()
        for i = 0, 999 do
            if sampIsPlayerConnected(i) then
                local nick = sampGetPlayerNickname(i)
                sampAddChatMessage(nick..'[' .. i ..']')
            end
        end
    end)

        imgui.Process = false

        while true do
            wait(0)





    function imgui.OnDrawFrame()
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(577, 300), imgui.Cond.FirstUseEver)

        if not main_window_state.v then
            imgui.Process = false
        end

            imgui.Begin("Evolve Helper BETA 1.0.0 bY E E E E E E E", main_window_state, imgui.WindowFlags.NoResize)
            imgui.Text(u8"                           Работы:                                                        Транспорт:")
            imgui.BeginChild(u8"Работы", imgui.ImVec2(250, 100), true)
            imgui.ToggleButton('##anti_drop', anti_drop)
            imgui.SameLine()
            imgui.Text(u8'Анти дроп обьектов')
            imgui.SameLine()
            imgui.TextQuestion(u8'Вы не будете ронять мешок или другой любой обьект в руках. !WARNING!: Иногда может кикать!')
            imgui.ToggleButton('##sbiv', sbiv)
            imgui.SameLine()
            imgui.Text(u8'Авто сбив отдышки')
            imgui.SameLine()
            imgui.TextQuestion(u8'После удара у вашего персонажа не будет отдышки')
            imgui.ToggleButton('##sbiv_piss', sbiv_piss)
            imgui.SameLine()
            imgui.Text(u8'Сбив на /piss (шоб по гетто \nящерски выглядила)')
            imgui.SameLine()
            imgui.TextQuestion(u8'Активация: R + 3')
            imgui.EndChild()

            imgui.SameLine()
            imgui.BeginChild("Транспорт", imgui.ImVec2(313, 100), true)
            imgui.ToggleButton('##speedcar', speedcar)
            imgui.SameLine()
            imgui.Text(u8'Спидометр(для мопедов)')
            imgui.SameLine()
            imgui.TextQuestion(u8'Как мы знаем, на Evolve нету спидометра когда сидишь за мопедом, это функция исправляет это!')
            imgui.ToggleButton('##taxi', taxi)
            imgui.SameLine()
            imgui.Text(u8'Отблагодарить таксиста за поездку (N + M)')
            imgui.SameLine()
            imgui.TextQuestion(u8'хз зач я это добавил, а может. B релизе этой надписи и не будет:(...')
            imgui.EndChild()

            imgui.Text(u8"                           Разное:")
            imgui.BeginChild(u8"Разное", imgui.ImVec2(410, 100), true)
            imgui.ToggleButton('##chat_id', chat_id)
            imgui.SameLine()
            imgui.Text(u8'Ники игроков в чате[BETA]')
            imgui.SameLine()
            imgui.TextQuestion(u8'Не работает на Evolve, но на других работает(hackmysoftware)')
            imgui.ToggleButton('##aptechka', aptechka)
            imgui.SameLine()
            imgui.Text(u8'Автоматически принимает вещества, активация:  R + 2')
            imgui.SameLine()
            imgui.TextQuestion(u8'При нажатии R + 2 игрок автоматически введёт "/usedrugs 15"')
            imgui.ToggleButton('##esc', esc)
            imgui.SameLine()
            imgui.Text(u8'Игнор надписей по типу "Не флуди!"')
            imgui.SameLine()
            imgui.TextQuestion(u8'Рил кому то не ясно?')
            imgui.ToggleButton('##radius_cmd', radius_cmd)
            imgui.SameLine()
            imgui.Text(u8'ид игроков в радиусе')
            imgui.EndChild()

            imgui.SetCursorPosY(220)
            imgui.SetCursorPosX(440)
            imgui.Text(u8'Автор на BlastHack:')
            imgui.SetCursorPosY(239)
            imgui.SetCursorPosX(440)
            if imgui.Button('Copy url') then
                setClipboardText('https://www.blast.hk/members/495401/')
            end
            imgui.End()

        end


function imgui.TextQuestion(text)
  imgui.TextDisabled('(?)')
      if imgui.IsItemHovered() then
            imgui.BeginTooltip()
          imgui.PushTextWrapPos(450)
          imgui.TextUnformatted(text)
          imgui.PopTextWrapPos()
          imgui.EndTooltip()
      end
    end

function hook.onSendPlayerSync(data)
    if anti_drop.v then
        data.keysData = 0
    end
end



function onScriptTerminate(script, quitGame)
    if script == thisScript() then
        sampAddChatMessage("{F24B4B}[Evolve Helper]:{FFFFFF} Скрипт был {F24B4B}крашнут{FFFFFF}, нажмите {F24B4B}CNTRL{FFFFFF} + {F24B4B}R{FFFFFF} чтобы перезагрузить", -1)
        printStringNow("~r~Evolve ~w~Helper ~r~ OFF", 2500)
    end
end

function hook.onServerMessage(color, text)
    if chat_id.v then
        for i = 0, 999 do
            if sampIsPlayerConnected(i) then
                local nick = sampGetPlayerNickname(i)
                if text:find (nick) then
                    return {color, text..'[' ..i.. ']'}
                end
            end
        end
    end
end
function search()
    if radius_cmd.v then
        for k,v in pairs(getAllChars()) do
            x, y, z = getCharCoordinates(PLAYER_PED)
            mX, mY, mZ = getCharCoordinates(v)
            dist = getDistanceBetweenCoords3d(x, y, z, mX, mY, mZ)
                if dist <= 5 then
                    idv = sampGetPlayerIdByCharHandle(v)
                    sampSendChat('/pseat'.. idv)
                end
        end
    end
    if sbiv_piss.v then
        if not sampIsDialogActive() and not sampIsChatInputActive() then
            if isKeyDown(VK_R) and isKeyJustPressed(VK_3) then
                sampSendChat("/piss")
            end
        end
    end
    if taxi.v then
        if not sampIsDialogActive() and not sampIsChatInputActive() then
            if isKeyDown(VK_N) and isKeyJustPressed(VK_M) then
                sampSendChat('От души брат)')
                wait(1500)
                sampSendChat('Удачи')
                wait(1000)
                sampSendChat(')')
            end
        end
    end
    if speedcar.v then
        speed = getCharSpeed(PLAYER_PED)
        carspeed = tonumber(speed)
            if isCharInAnyCar(PLAYER_PED) and carspeed >= 0 then
                printString(math.floor(carspeed), 500)
            end
    end
    if aptechka.v then
        if not sampIsDialogActive() and not sampIsChatInputActive() then
            if isKeyDown(VK_R) and isKeyJustPressed(VK_2) then
                sampSendChat("/usedrugs 15")
            end
        end
    end

    if sbiv.v then
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
                idanimation = sampGetPlayerAnimationId(id)
                    if idanimation == 1191 then
                        wait(1)
                        x, y, z = getCharCoordinates(PLAYER_PED)
                        zi = z -1
                        setCharCoordinates(PLAYER_PED, x, y, zi)
                    end
    end
end
end
end
помагити плес

[ML] (error) EvolveHelper.lua: C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:41: attempt to index global 'main_window_state' (a nil value)
stack traceback:
C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:41: in function <C:\Program Files (x86)\SAMP\moonloader\EvolveHelper.lua:40>
[ML] (error) EvolveHelper.lua: Script died due to an error. (4003466C)
Lua:
script_author('E E E E E E E')

require 'lib.moonloader'
local hook = require 'lib.samp.events'
local imgui = require 'imgui'
local red = 0xF24B4B
imgui.ToggleButton = require('imgui_addons').ToggleButton
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

lua_thread.create(function()

local themes = import "resource/imgui_themes.lua"
local vkeys = require 'vkeys'

imgui.SwitchContext()
themes.SwitchColorTheme(2)

local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local anti_drop = imgui.ImBool(false)
local chat_id = imgui.ImBool(false)
local sbiv = imgui.ImBool(false)
local test = imgui.ImBool(false)
local aptechka = imgui.ImBool(false)
local speedcar = imgui.ImBool(false)
local taxi = imgui.ImBool(false)
local sbiv_piss = imgui.ImBool(false)
local esc = imgui.ImBool(false)
local radius_cmd = imgui.ImBool(false)

end)

function main()
    repeat wait(0) until isSampAvailable()
    printStringNow("~r~Evolve~w~ Helper ~g~ON", 1500)
    wait(1500)
    printString('~r~Evolve~w~ Helper: ~r~/e.menu', 1500)
    sampRegisterChatCommand("e.menu", function()
        main_window_state.v = not main_window_state.v
                imgui.Process = main_window_state.v
    end)
   
    sampRegisterChatCommand("getplayers", function()
        for i = 0, 999 do
            if sampIsPlayerConnected(i) then
                local nick = sampGetPlayerNickname(i)
                sampAddChatMessage(nick..'[' .. i ..']')
            end
        end
    end)

        imgui.Process = false

        while true do
            wait(0)





    function imgui.OnDrawFrame()
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(577, 300), imgui.Cond.FirstUseEver)

        if not main_window_state.v then
            imgui.Process = false
        end

            imgui.Begin("Evolve Helper BETA 1.0.0 bY E E E E E E E", main_window_state, imgui.WindowFlags.NoResize)
            imgui.Text(u8"                           Работы:                                                        Транспорт:")
            imgui.BeginChild(u8"Работы", imgui.ImVec2(250, 100), true)
            imgui.ToggleButton('##anti_drop', anti_drop)
            imgui.SameLine()
            imgui.Text(u8'Анти дроп обьектов')
            imgui.SameLine()
            imgui.TextQuestion(u8'Вы не будете ронять мешок или другой любой обьект в руках. !WARNING!: Иногда может кикать!')
            imgui.ToggleButton('##sbiv', sbiv)
            imgui.SameLine()
            imgui.Text(u8'Авто сбив отдышки')
            imgui.SameLine()
            imgui.TextQuestion(u8'После удара у вашего персонажа не будет отдышки')
            imgui.ToggleButton('##sbiv_piss', sbiv_piss)
            imgui.SameLine()
            imgui.Text(u8'Сбив на /piss (шоб по гетто \nящерски выглядила)')
            imgui.SameLine()
            imgui.TextQuestion(u8'Активация: R + 3')
            imgui.EndChild()

            imgui.SameLine()
            imgui.BeginChild("Транспорт", imgui.ImVec2(313, 100), true)
            imgui.ToggleButton('##speedcar', speedcar)
            imgui.SameLine()
            imgui.Text(u8'Спидометр(для мопедов)')
            imgui.SameLine()
            imgui.TextQuestion(u8'Как мы знаем, на Evolve нету спидометра когда сидишь за мопедом, это функция исправляет это!')
            imgui.ToggleButton('##taxi', taxi)
            imgui.SameLine()
            imgui.Text(u8'Отблагодарить таксиста за поездку (N + M)')
            imgui.SameLine()
            imgui.TextQuestion(u8'хз зач я это добавил, а может. B релизе этой надписи и не будет:(...')
            imgui.EndChild()

            imgui.Text(u8"                           Разное:")
            imgui.BeginChild(u8"Разное", imgui.ImVec2(410, 100), true)
            imgui.ToggleButton('##chat_id', chat_id)
            imgui.SameLine()
            imgui.Text(u8'Ники игроков в чате[BETA]')
            imgui.SameLine()
            imgui.TextQuestion(u8'Не работает на Evolve, но на других работает(hackmysoftware)')
            imgui.ToggleButton('##aptechka', aptechka)
            imgui.SameLine()
            imgui.Text(u8'Автоматически принимает вещества, активация:  R + 2')
            imgui.SameLine()
            imgui.TextQuestion(u8'При нажатии R + 2 игрок автоматически введёт "/usedrugs 15"')
            imgui.ToggleButton('##esc', esc)
            imgui.SameLine()
            imgui.Text(u8'Игнор надписей по типу "Не флуди!"')
            imgui.SameLine()
            imgui.TextQuestion(u8'Рил кому то не ясно?')
            imgui.ToggleButton('##radius_cmd', radius_cmd)
            imgui.SameLine()
            imgui.Text(u8'ид игроков в радиусе')
            imgui.EndChild()

            imgui.SetCursorPosY(220)
            imgui.SetCursorPosX(440)
            imgui.Text(u8'Автор на BlastHack:')
            imgui.SetCursorPosY(239)
            imgui.SetCursorPosX(440)
            if imgui.Button('Copy url') then
                setClipboardText('https://www.blast.hk/members/495401/')
            end
            imgui.End()

        end


function imgui.TextQuestion(text)
  imgui.TextDisabled('(?)')
      if imgui.IsItemHovered() then
            imgui.BeginTooltip()
          imgui.PushTextWrapPos(450)
          imgui.TextUnformatted(text)
          imgui.PopTextWrapPos()
          imgui.EndTooltip()
      end
    end

function hook.onSendPlayerSync(data)
    if anti_drop.v then
        data.keysData = 0
    end
end



function onScriptTerminate(script, quitGame)
    if script == thisScript() then
        sampAddChatMessage("{F24B4B}[Evolve Helper]:{FFFFFF} Скрипт был {F24B4B}крашнут{FFFFFF}, нажмите {F24B4B}CNTRL{FFFFFF} + {F24B4B}R{FFFFFF} чтобы перезагрузить", -1)
        printStringNow("~r~Evolve ~w~Helper ~r~ OFF", 2500)
    end
end

function hook.onServerMessage(color, text)
    if chat_id.v then
        for i = 0, 999 do
            if sampIsPlayerConnected(i) then
                local nick = sampGetPlayerNickname(i)
                if text:find (nick) then
                    return {color, text..'[' ..i.. ']'}
                end
            end
        end
    end
end
function search()
    if radius_cmd.v then
        for k,v in pairs(getAllChars()) do
            x, y, z = getCharCoordinates(PLAYER_PED)
            mX, mY, mZ = getCharCoordinates(v)
            dist = getDistanceBetweenCoords3d(x, y, z, mX, mY, mZ)
                if dist <= 5 then
                    idv = sampGetPlayerIdByCharHandle(v)
                    sampSendChat('/pseat'.. idv)
                end
        end
    end
    if sbiv_piss.v then
        if not sampIsDialogActive() and not sampIsChatInputActive() then
            if isKeyDown(VK_R) and isKeyJustPressed(VK_3) then
                sampSendChat("/piss")
            end
        end
    end
    if taxi.v then
        if not sampIsDialogActive() and not sampIsChatInputActive() then
            if isKeyDown(VK_N) and isKeyJustPressed(VK_M) then
                sampSendChat('От души брат)')
                wait(1500)
                sampSendChat('Удачи')
                wait(1000)
                sampSendChat(')')
            end
        end
    end
    if speedcar.v then
        speed = getCharSpeed(PLAYER_PED)
        carspeed = tonumber(speed)
            if isCharInAnyCar(PLAYER_PED) and carspeed >= 0 then
                printString(math.floor(carspeed), 500)
            end
    end
    if aptechka.v then
        if not sampIsDialogActive() and not sampIsChatInputActive() then
            if isKeyDown(VK_R) and isKeyJustPressed(VK_2) then
                sampSendChat("/usedrugs 15")
            end
        end
    end

    if sbiv.v then
        _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
                idanimation = sampGetPlayerAnimationId(id)
                    if idanimation == 1191 then
                        wait(1)
                        x, y, z = getCharCoordinates(PLAYER_PED)
                        zi = z -1
                        setCharCoordinates(PLAYER_PED, x, y, zi)
                    end
    end
end
end
end
помагити плес
помагити
 
Последнее редактирование:

DZONE

Известный
185
200
Как мне это player;player;player; разбить на
player
player
player

вроде через gmatch надо, только хз как
 

E E E E E E E

Активный
154
28
ошибок нет, но и линии нету
Lua:
require 'lib.moonloader'

local enable = false

function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand("dhack", function(id)
        sampAddChatMessage("Успешно", -1)
        enable = not enable
            end)

    while true do
        wait(0)
        if enable and id ~= nil then
            ids = tonumber(id)
            ped = sampGetCharHandleBySampPlayerId(ids)
              x, y = getCharCoordinates(PLAYER_PED)
                mX, mY = getCharCoordinates(ped)
                dist = getDistanceBetweenCoords3d(x, y, mX, mY)
                lua_thread.create(function()
                    renderDrawLine(x, y, mX, mY, 10.0, 0xFFD00000)
            end)
        end
    end
end
 

вайега52

Налуашил состояние
Модератор
2,976
3,094
Хотел сделать два параллельно выполняющихся кода в беск. цикле, но шот пошло не так и теперь скрипт не видит задержку, в чем я тупой?
Lua:
if slots.type:find("rpc out") then
    lua_thread.create(function()
        local bs = RakLuaBitStream.new()
        for _, data in pairs(slots.data) do
            if data[1]:find("float") then
                bs:writeFloat(data[2][0])
            elseif data[1]:find("uint") then
                if data[1]:find("uint8") then
                    bs:writeUInt8(data[2][0])
                elseif data[1]:find("uint16") then
                    bs:writeUInt16(data[2][0])
                elseif data[1]:find("uint32") then
                    bs:writeUInt32(data[2][0])
                end
            elseif data[1]:find("int") then
                if data[1]:find("int8") then
                    bs:writeInt8(data[2][0])
                elseif data[1]:find("int16") then
                    bs:writeInt16(data[2][0])
                elseif data[1]:find("int32") then
                    bs:writeInt32(data[2][0])
                end
            elseif data[1]:find("string") then
                if data[1]:find("string8") then
                    bs:writeUInt8(#u8:decode(str(data[2])))
                    bs:writeString(u8:decode(str(data[2])))
                elseif data[1]:find("string32") then
                    bs:writeUInt32(#u8:decode(str(data[2])))
                    bs:writeString(u8:decode(str(data[2])))
                end
            elseif data[1]:find("encoded") then
                bs:writeEncoded(u8:decode(str(data[2])))
            elseif data[1]:find("bool") then
                bs:writeBool(data[2][0])
            end
        end
        bs:sendRPC(slots.id)
        wait(RakNet.scenarios[i].wait[0])
    end)
end

Без потоков задержка была, но тогда действия шли друг за другом, а не параллельно, как мне надо

Upd: даже с потоками действия идут не параллельно + без задержки
 

Pashyka

Участник
220
17
C++:
LoadKeyboardLayout("00000409", KLF_ACTIVATE);    //английская раскладка
LoadKeyboardLayout("00000419", KLF_ACTIVATE);    //русская раскладка
Сорри, я ffi вообще никогда не юзал, что не верно?
Lua:
local ffi = require("ffi")
if imgui.Button(fa.ICON_FA_CLONE, imgui.ImVec2(120,20)) then
    ffi.LoadKeyboardLayout("00000409", KLF_ACTIVATE)
    setClipboardText(textrep)
end