Помощь с луа

ghostex

Активный
Автор темы
179
31
[ML] (error) helper2.lua: ...pob\Desktop\GTA 140K BY DAPO SHOW\moonloader\helper2.lua:42: '<eof>' expected near 'end'
[ML] (error) helper2.lua: Script died due to an error. (11CA73EC)

LUA:
require "lib.moonloader"


if not doesFileExist('moonloader/config/delay.ini') then inicfg.save(mainIni,'delay.ini') end

function main()
   while not isSampAvailable() do wait(100) end
   while true do
   wait(0)
    result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
   if not sampIsDialogActive() and not sampIsChatInputActive() then
        if isKeyDown(97) then
        sampSetChatInputEnabled(true)
        sampSetChatInputTextWithDelay('/id ' ..id, math.random(2, 70))
                wait (75)
                setVirtualKeyDown(13, true)
                wait(5)
                setVirtualKeyDown(13, false)
        end
                if isKeyJustPressed(98) then
        sampSetChatInputEnabled(true)
        sampSetChatInputTextWithDelay('/time', math.random(2, 70))
                wait (75)
                setVirtualKeyDown(13, true)
                wait(5)
                setVirtualKeyDown(13, false)
                end
                if isKeyJustPressed(99) then
        sampSetChatInputEnabled(true)
        sampSetChatInputTextWithDelay('/stats', math.random(2, 70))
                wait (75)
                setVirtualKeyDown(13, true)
                wait(5)
                setVirtualKeyDown(13, false)
                end
    end

function sampSetChatInputTextWithDelay(text, delay)
    local array = {}
    for i in text:gmatch('[^%z]') do
        wait(delay)
        table.insert(array, i)
        sampSetChatInputText(table.concat(array))
    end
 
Решение
Во функции main не закрыт цикл (8 строка) end-ом в 37 и 38 строке сама функция main не закрыта и функция sampSetChatInputTextWithDelay также не закрыта end 45 строкой.
А и ещё, у тебя используются задержки в главном потоке main, т.е. функция, что влечёт заморозкой скрипта на время задержки. В твоём первоначальном простом скрипте ещё не очень критично, но лучше создавать отдельный потом под свои нужды, где используются задержки.


Приблизительно так, чтобы в главном потомке всегда была 0 задержка.
Lua:
function main()
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if not sampIsDialogActive() and not sampIsChatInputActive() then...

Hatiko

Известный
Проверенный
1,533
648
Во функции main не закрыт цикл (8 строка) end-ом в 37 и 38 строке сама функция main не закрыта и функция sampSetChatInputTextWithDelay также не закрыта end 45 строкой.
А и ещё, у тебя используются задержки в главном потоке main, т.е. функция, что влечёт заморозкой скрипта на время задержки. В твоём первоначальном простом скрипте ещё не очень критично, но лучше создавать отдельный потом под свои нужды, где используются задержки.


Приблизительно так, чтобы в главном потомке всегда была 0 задержка.
Lua:
function main()
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
        result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
        if not sampIsDialogActive() and not sampIsChatInputActive() then
            if isKeyDown(97) then
                 lua_thread.create(function()
                     sampSetChatInputEnabled(true)
                     sampSetChatInputTextWithDelay('/id ' ..id, math.random(2, 70))
                     wait (75)
                     setVirtualKeyDown(13, true)
                     wait(5)
                     setVirtualKeyDown(13, false)
                 end)
            end
            if isKeyJustPressed(98) then
                lua_thread.create(function()
                    sampSetChatInputEnabled(true)
                    sampSetChatInputTextWithDelay('/time', math.random(2, 70))
                    wait (75)
                    setVirtualKeyDown(13, true)
                    wait(5)
                    setVirtualKeyDown(13, false)
                end)
            end
            if isKeyJustPressed(99) then
                lua_thread.create(function()
                    sampSetChatInputEnabled(true)
                    sampSetChatInputTextWithDelay('/stats', math.random(2, 70))
                    wait (75)
                    setVirtualKeyDown(13, true)
                    wait(5)
                    setVirtualKeyDown(13, false)
                end)
            end
        end
    end
end
 
Последнее редактирование:
  • Нравится
Реакции: ghostex