Изменить функцию скрипта

HaU

Активный
Автор темы
191
93
Я многого не прошу, изменить функцию показа чисел на экране с поочередного на случайный
 

Вложения

  • y.lua
    772 байт · Просмотры: 3
Решение
Lua:
function main()
    local delay = 1000
    sampRegisterChatCommand('setdelay', function(arg)
        if arg:match('%d+') then
            delay = tonumber(arg)
            sampAddChatMessage('new delay = '..delay, -1)
        else
            sampAddChatMessage('incorrect delay', -1)
        end
    end)
    sampRegisterChatCommand('startnum', function()
        active = not active
        sampAddChatMessage(active and 'on' or 'off', -1)
    end)
    while true do wait(delay)
        if active then
            math.randomseed(os.time()^3.14)
            printStyledString(math.random(0,1), delay, 4)
        end
    end
end

стар батерфляй

Участник
42
73
Lua:
function main()
    local delay = 1000
    sampRegisterChatCommand('setdelay', function(arg)
        if arg:match('%d+') then
            delay = tonumber(arg)
            sampAddChatMessage('new delay = '..delay, -1)
        else
            sampAddChatMessage('incorrect delay', -1)
        end
    end)
    sampRegisterChatCommand('startnum', function()
        active = not active
        sampAddChatMessage(active and 'on' or 'off', -1)
    end)
    while true do wait(delay)
        if active then
            math.randomseed(os.time()^3.14)
            printStyledString(math.random(0,1), delay, 4)
        end
    end
end
 
  • Нравится
Реакции: HaU