как выполнить функцию от 1 до 5 раз?

wefwefwefwef

Участник
Автор темы
31
10
Версия MoonLoader
Другое
как выполнить функцию от 1 до 5 раз?
runCommand('!tdclick '..textDrawId..'')
 

wefwefwefwef

Участник
Автор темы
31
10
рандомное количество раз от 1 до 5?
+

Данный способ производит 1 клик
Lua:
if(textDrawString == "selecticon2") then
    math.random(math.randomseed(os.time()))
    local rand = math.random(1, 5)
    for i = 0, rand do defCallAdd(1000, false, function() runCommand('!tdclick '..textDrawId..'') end) end
    end
 

Rice.

https://t.me/riceoff
Модератор
1,691
1,436
Lua:
math.randomseed(os.clock())
local times = math.random(5) -- рандомное число от 1 до 5
while times > 0 do
    -- code...
    time = times - 1
end
А не проще?
Lua:
math.randomseed(os.clock())
local times = math.random(5)
for i = 1, tonumber(times) do
    --code
end
 
  • Нравится
Реакции: wefwefwefwef

wefwefwefwef

Участник
Автор темы
31
10
В ракботе нет функии wait, пробую defCallAdd все равно все клики разом прожимает
Lua:
    if(textDrawString == "selecticon2") then
    defCallAdd(5000, false, function()
    math.randomseed(os.clock())
    local times = math.random(5)
    for i = 1, times do
    runCommand('!tdclick '..textDrawId..'')
    end
    end)
    end


defCallAdd(delay, repeat, func[, params])