Почему возникла ошибка?

ArtemMakenzi

Новичок
Автор темы
17
11
Версия SA-MP
  1. 0.3.7 (R1)
Lua:
require 'lib.moonloader'

function main()
if not isSampLoaded() and not isSampfuncsLoaded then return end
    while not isSampAvailable() do wait(500) end
    
    sampRegisterChatCommand('timer',
    function(param)
        timertime = os.time() + tonumber(param)
    end)
    
    while true do
        wait(0)
        if timertime >= os.time() then
            timeInSeconds = timertime - os.time()
            minutes = math.floor(timeInSeconds / 60)
            seconds = math.floor(timeInSeconds - minutes * 60)
            printStringNow(string.format('%02d:%02d', minutes, seconds), 1000)
        end
    end
end

gta_sa_GMRxjVqdx1.png
 

YarikVL

Известный
Проверенный
4,797
1,813
Lua:
require 'lib.moonloader'

function main()
if not isSampLoaded() and not isSampfuncsLoaded then return end
    while not isSampAvailable() do wait(500) end
   
    sampRegisterChatCommand('timer',
    function(param)
        timertime = os.time() + tonumber(param)
    end)
   
    while true do
        wait(0)
        if timertime >= os.time() then
            timeInSeconds = timertime - os.time()
            minutes = math.floor(timeInSeconds / 60)
            seconds = math.floor(timeInSeconds - minutes * 60)
            printStringNow(string.format('%02d:%02d', minutes, seconds), 1000)
        end
    end
end

Посмотреть вложение 153951
Бл ну переводчиком же понятно, ты пытаешься сравнить "ничего" с числом
То есть переменная timertime имеет значение nil, либо для os.time() в 14 строке надо прописывать tonumber ( скорее всего переменная timertime ) так что пробуй выводить значения с которыми ты взаимодействуешь в 14 строке и увидишь ошибку
Либо надо для os.time() написать tonumber, либо ты команду вводишь так: /timer и после пробела, после команды, нечего не вводишь