краш скрипта после ввода команды

Cypher

Активный
Автор темы
224
55
Версия MoonLoader
.026-beta
1:
act = false

act = false

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("bronik",arg)
    while true do
        wait(0)

        end
    end

function bronik(arg)
    act = not act
armour = getCharArmour(PLAYER_PED)
    if act and armour < 1 then
thr:run()
    end
end

function thread_function()
wait(5000)
sampSendChat("/armour")
end

ПОЖАЛУЙСТА НЕ СМОТРИТЕ НА КРИВУЮ ТАБУЛЯЦИЮ!!!!
после ввода /bronik крашится скрипт


[ML] (error) autoarmour.lua: attempt to call a nil value
stack traceback:
[ML] (error) autoarmour.lua: Script died due to an error. (0DB65B04)
 
  • Злость
Реакции: qdIbp
Решение
Lua:
local act = false

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("bronik",function()act = not act print(act and 'вкл' or 'выкл')end)
    while true do wait(0)
        if act then
            if getCharArmour(PLAYER_PED) < 1 then
                wait(5000)
                sampSendChat("/armour")
            end
        end
    end
end
Lua:
local act = false

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("bronik",function()act = not act print(act and 'вкл' or 'выкл')end)
    while true do wait(0)
        if act then
            if getCharArmour(PLAYER_PED) < 1 then
                wait(5000)
                if getCharArmour(PLAYER_PED) <...

Cypher

Активный
Автор темы
224
55
Lua:
local act = false

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("bronik",function()act = not act print(act and 'вкл' or 'выкл')end)
    while true do wait(0)
        if act then
            if getCharArmour(PLAYER_PED) < 1 then
                wait(5000)
                sampSendChat("/armour")
            end
        end
    end
end
Уже пытался делать такое, не знаю по какой причине но он просто бесконечно надевает броник и снимает его каждые 5 сек, потому и обратился сюда
 
  • Эм
Реакции: qdIbp

qdIbp

Автор темы
Проверенный
1,387
1,143
Уже пытался делать такое, не знаю по какой причине но он просто бесконечно надевает броник и снимает его каждые 5 сек, потому и обратился сюда
Попробуй, мне интересно так же будет
 
  • Нравится
Реакции: kyrtion

Cypher

Активный
Автор темы
224
55
Попробуй, мне интересно так же будет
я попробовал, также
1668777393552.png


-1 это бесконечное ожидание, так что цикл вроде так не будет работать
Дак в том то и суть чтобы цикл не работал если его не используют..
 
  • Эм
Реакции: qdIbp

qdIbp

Автор темы
Проверенный
1,387
1,143
Попробуй так, если не получится то арз говно
Lua:
local act = false

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("bronik",function()act = not act print(act and 'вкл' or 'выкл')end)
    while true do wait(0)
        if act then
            wait(5000)
            if getCharArmour(PLAYER_PED) < 1 then
                sampSendChat("/armour")
            end
        end
    end
end
 
  • Нравится
Реакции: kyrtion и Cypher

kyrtion

Известный
666
245
Lua:
local act = false

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("bronik",function()act = not act print(act and 'вкл' or 'выкл')end)
    while true do wait(0)
        if act then
            if getCharArmour(PLAYER_PED) < 1 then
                wait(5000)
                sampSendChat("/armour")
            end
        end
    end
end
Lua:
local act = false

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("bronik",function()act = not act print(act and 'вкл' or 'выкл')end)
    while true do wait(0)
        if act then
            if getCharArmour(PLAYER_PED) < 1 then
                wait(5000)
                if getCharArmour(PLAYER_PED) < 1 then sampSendChat("/armour") end
            end
        end
    end
end
(кнш, я говнокодер, а шо)
Попробуйте, @Cypher
 
  • Эм
  • Нравится
Реакции: Cypher и qdIbp