Активация / деактивация командой

NoName1233

Участник
Автор темы
39
3
Версия MoonLoader
.027.0-preview
Помогите сделать так чтобы при написании команды один раз,она включалась.Когда второй раз написали,она выключалась. Плиз помогите!!
вот код:
Код:
script_name("FLOODER")
script_author("The_Desert")
script_description("123")

require "lib.moonloader"

local sampev = require 'lib.samp.events'
local white_color = 0xFFFFFF
local white_color_text = "{FFFFFF}"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("floodcapt", flood_cmd)
    sampRegisterChatCommand("offcapt", offcapt_cmd)
    thread = lua_thread.create_suspended(func111)
    while true do
        wait(0)
      end
    end
    function flood_cmd(arg)
      thread:run()
    end

function func111()
  i = 1
sampAddChatMessage("Флудер активирован!", 0x90EE90)
  while i <= 30 do
    wait(1000)
    sampSendChat('/capture ')
    wait(1000)
    i = i+1
  end
end
 

wulfandr

Известный
637
260
Lua:
script_name("FLOODER")
script_author("The_Desert")
script_description("123")

require "lib.moonloader"

local sampev = require 'lib.samp.events'

local activate = false

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("floodcapt", flood_cmd)
    while true do wait(0) end
    wait(-1)
end

function flood_cmd()
    activate = not activate if activate then i = 1 sampAddChatMessage('Вы активировали флудер.', 0x90EE90) else i = 31 sampAddChatMessage('Вы выключили флудер.', 0x90EE90) end
    lua_thread.create(function()
        while i <= 30 do
            sampSendChat('/capture')
            wait(1000)
            i = i + 1
            if i == 30 then activate = false end
        end
    end)
end
 

NoName1233

Участник
Автор темы
39
3
Lua:
script_name("FLOODER")
script_author("The_Desert")
script_description("123")

require "lib.moonloader"

local sampev = require 'lib.samp.events'

local activate = false

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("floodcapt", flood_cmd)
    while true do wait(0) end
    wait(-1)
end

function flood_cmd()
    activate = not activate if activate then i = 1 sampAddChatMessage('Вы активировали флудер.', 0x90EE90) else i = 31 sampAddChatMessage('Вы выключили флудер.', 0x90EE90) end
    lua_thread.create(function()
        while i <= 30 do
            sampSendChat('/capture')
            wait(1000)
            i = i + 1
            if i == 30 then activate = false end
        end
    end)
end
спасибо огромное))))