[LUA] Помогите найти ошибку в коде. Прошу!

Статус
В этой теме нельзя размещать новые ответы.

lovandog

Активный
Автор темы
226
98
Не могу найти ошибку. Я новичок, хотел сделать бота, который когда видит, что меньше 80хп, курит сигару. Не могу найти ошибку, помогите пожалуйста!

Это LUA

Код:
function main()
    repeat wait(0) until isSampAvailable()

        sampRegisterChatCommand("smk", smk)
        smoke = false

        while true do
            wait(0)
            health = getCharHealth(PLAYER_PED)

            if smoke then
                    if ( health < 80 ) then
                        sampSendChat("/smoke")
                  end

          end
end


function smk()
        smoke = not smoke
        sampAddChatMessage("Запущен!", -1)
end
end
 
Решение
Вот, ты там с end'ами накосячил. Вроде должно работать
Lua:
function main()
    repeat wait(0) until isSampAvailable()

    sampRegisterChatCommand("smk", smk)
    smoke = false

    while true do
        wait(0)
        health = getCharHealth(PLAYER_PED)

        if smoke then
            if ( health < 80 ) then
                sampSendChat("/smoke")
            end
        end
    end
end


function smk()
    smoke = not smoke
    sampAddChatMessage("Запущен!", -1)
end

hexando

Известный
50
47
Вот, ты там с end'ами накосячил. Вроде должно работать
Lua:
function main()
    repeat wait(0) until isSampAvailable()

    sampRegisterChatCommand("smk", smk)
    smoke = false

    while true do
        wait(0)
        health = getCharHealth(PLAYER_PED)

        if smoke then
            if ( health < 80 ) then
                sampSendChat("/smoke")
            end
        end
    end
end


function smk()
    smoke = not smoke
    sampAddChatMessage("Запущен!", -1)
end
 
  • Нравится
Реакции: sport-s и lovandog

lovandog

Активный
Автор темы
226
98
Вот, ты там с end'ами накосячил. Вроде должно работать
Lua:
function main()
    repeat wait(0) until isSampAvailable()

    sampRegisterChatCommand("smk", smk)
    smoke = false

    while true do
        wait(0)
        health = getCharHealth(PLAYER_PED)

        if smoke then
            if ( health < 80 ) then
                sampSendChat("/smoke")
            end
        end
    end
end


function smk()
    smoke = not smoke
    sampAddChatMessage("Запущен!", -1)
end

Блять, чел огромное тебе спасибо. Сейчас проверю на работоспособность

UPD
ОГРОМНОЕ СПАСИБО. Я никогда так не радовался. ОНО РАБОТАЕТ

UPD
Я только сейчас понял насколько я затупил с эндами. Спасибо, что нашел время помочь. Счастья, здоровья, а я уже говорю как бабулька.
 
Последнее редактирование:
  • Нравится
Реакции: sport-s и hexando
Статус
В этой теме нельзя размещать новые ответы.