В чём моя ошибка?

я не клоун

Активный
Автор темы
134
25
Версия MoonLoader
Другое
Добрый день, я новичёк в луа, буквально 1 день, мне бы было интересно в чём моя ошибка здесь?

Lua:
function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(9000) end
  sampAddChatMessage('{0000CD} Aктивация: /sliv ')
  sampAddChatMessage('{7CFC00} Aвтором чуда является: help_me ')
 
 while not isSampAvailable() do wait(100) end
sampRegisterChatCommand("sliv", function()
      sampSendChat("/apanel")
      end)
         while true do
       wait(0)
        if state then
            if os.clock() - time >= 1 then -- 1 sek
                sampSendChat('/apanel')
                time = os.clock()
end)
wait(-1)

end
 

asprt

Известный
167
41
Добрый день, я новичёк в луа, буквально 1 день, мне бы было интересно в чём моя ошибка здесь?

Lua:
function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(9000) end
  sampAddChatMessage('{0000CD} Aктивация: /sliv ')
  sampAddChatMessage('{7CFC00} Aвтором чуда является: help_me ')
 
 while not isSampAvailable() do wait(100) end
sampRegisterChatCommand("sliv", function()
      sampSendChat("/apanel")
      end)
         while true do
       wait(0)
        if state then
            if os.clock() - time >= 1 then -- 1 sek
                sampSendChat('/apanel')
                time = os.clock()
end)
wait(-1)

end
у тебя нигде не активируется переменная state
 

Liquit

Известный
280
107
Добрый день, я новичёк в луа, буквально 1 день, мне бы было интересно в чём моя ошибка здесь?

Lua:
function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(9000) end
  sampAddChatMessage('{0000CD} Aктивация: /sliv ')
  sampAddChatMessage('{7CFC00} Aвтором чуда является: help_me ')
 
 while not isSampAvailable() do wait(100) end
sampRegisterChatCommand("sliv", function()
      sampSendChat("/apanel")
      end)
         while true do
       wait(0)
        if state then
            if os.clock() - time >= 1 then -- 1 sek
                sampSendChat('/apanel')
                time = os.clock()
end)
wait(-1)

end
Внимательно пересмотри код и посмотри, что ты не закрыл два ифа, и добавили лишнюю скобку в конце. В луа не как в питухоне, ифы надо закрывать
 
  • Ха-ха
Реакции: eqzzz

asprt

Известный
167
41
Lua:
require 'lib.moonloader'
require 'lib.sampfuncs'
require 'lib.samp.events'

local active = false
local reason = 'cheat'
local days = 30
local delay = 3000

function main()
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand('sliv', function()
        active = not active
        if active then
            lua_thread.create(function()
                for i = 0, sampGetMaxPlayerId() do
                     if sampIsPlayerConnected(i) then
                        sampSendChat('/ban '  .. i .. ' ' .. days .. ' ' .. reason)
                        wait(delay)
                    end
                 end
            end)
        end
    end)

    sampRegisterChatCommand('sliv.reason', function(param)
        if param == '' then
            sampAddChatMessage('wrong parameter, example: /sliv.reason cheat', -1)
        else
            reason = param
            sampAddChatMessage(reason, -1)
        end
    end)

    sampRegisterChatCommand('sliv.days', function(param)
        _days = tonumber(param)
        if type(_days) == 'number' then
            if param == '' then
                sampAddChatMessage('usage: /sliv.days [days]', -1)
            else
                days = _days
                sampAddChatMessage(days, -1)
            end
        else
            sampAddChatMessage('wrong parameter, example: /sliv.days 30', -1)
        end
    end)

    sampRegisterChatCommand('sliv.delay', function(param)
        _delay = tonumber(param)
        if type(_delay) == 'number' then
            if param == '' then
                sampAddChatMessage('usage: /sliv.delay [delay]', -1)
            else
                delay = _delay
                sampAddChatMessage(delay, -1)
            end
        else
            sampAddChatMessage('wrong parameter, example: /sliv.delay 3000', -1)
        end
    end)
end

/sliv - активация
/sliv.days - дни на сколько банить
/sliv.reason - причина
/sliv.delay - задержка между банами
 

qdIbp

Автор темы
Проверенный
1,450
1,191
Добрый день, я новичёк в луа, буквально 1 день, мне бы было интересно в чём моя ошибка здесь?

Lua:
function main()
  if not isSampfuncsLoaded() or not isSampLoaded() then return end
  while not isSampAvailable() do wait(9000) end
  sampAddChatMessage('{0000CD} Aктивация: /sliv ')
  sampAddChatMessage('{7CFC00} Aвтором чуда является: help_me ')
 
 while not isSampAvailable() do wait(100) end
sampRegisterChatCommand("sliv", function()
      sampSendChat("/apanel")
      end)
         while true do
       wait(0)
        if state then
            if os.clock() - time >= 1 then -- 1 sek
                sampSendChat('/apanel')
                time = os.clock()
end)
wait(-1)

end
🙀🙀🙀
Эмать, ну как так можно
Тогда уж лучше так

Lua:
local st, timer = false, 0

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
        sampAddChatMessage('{0000CD} Aктивация: /sliv ')
        sampAddChatMessage('{7CFC00} Aвтором чуда является: help_me ')
        sampRegisterChatCommand("sliv", function() st = not st print(st and 'true' or 'false') end)
    while true do wait(0)
        if st and os.time() > timer then -- если st равен true и время больше таймера то
            local xz = math.random(0, sampGetMaxPlayerId()) -- переменная с рандомным числом от 0 до макс кол-во чел на сервере
            if sampIsPlayerConnected(xz) then -- проверка подк ли игрок
                sampSendChat('/ban '..xz..' 30 Читы') -- отправляет смс в час
                timer = os.clock() + 1 -- 1 сек
            end
        end
    end
end
 
  • Влюблен
Реакции: SomaGnoma

asprt

Известный
167
41
🙀🙀🙀
Эмать, ну как так можно
Тогда уж лучше так

Lua:
            local xz = math.random(0, sampGetMaxPlayerId()) -- переменная с рандомным числом от 0 до макс кол-во чел на сервере
зачем ему рандомное число
 

qdIbp

Автор темы
Проверенный
1,450
1,191