Как правильно вставить код?

Капрал

Новичок
Автор темы
8
5
Версия MoonLoader
Другое
Есть два кода, надо сделать его одним, но как это сделать - я не знаю, ибо дурачек (не беситесь), прошу помощи. Если что из них должен получится биндер с таймером до след. активации команды из биндера.


1 Код: Биндер:
require "lib.moonloader"
function main()
sampRegisterChatCommand('timer', function()
        time = os.time() + 60
    end)
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(100) end
  while true do
  wait(0)
    if isKeyJustPressed(VK_NUMPAD3) then
      sampSendChat("/armour")
    end
  end
  end


2 Код: Таймер:
local time = 0
function main()
    sampRegisterChatCommand('timer', function()
        time = os.time() + 60
    end)
    while true do
        wait(0)
        if (time - os.time()) >= 0 then
            printStringNow(tostring(time - os.time()), 0)
        end
    end
end

Отдельное спасибо @CaJlaT и @ufdhbi за коды
 
Решение
Lua:
require "lib.moonloader"
local time = 0
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('timer', function()
        time = os.time() + 60
    end)
    while true do
        wait(0)
        if (time - os.time()) >= 0 then
            printStringNow(tostring(time - os.time()), 0)
        end
        if isKeyJustPressed(VK_NUMPAD3) and (time - os.time()) < 0 then
            sampSendChat("/armour")
        end
    end
end

CaJlaT

Овощ
Модератор
2,805
2,607
Lua:
require "lib.moonloader"
local time = 0
function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('timer', function()
        time = os.time() + 60
    end)
    while true do
        wait(0)
        if (time - os.time()) >= 0 then
            printStringNow(tostring(time - os.time()), 0)
        end
        if isKeyJustPressed(VK_NUMPAD3) and (time - os.time()) < 0 then
            sampSendChat("/armour")
        end
    end
end
 
  • Нравится
Реакции: Капрал