как сделать так, чтобы при заходе скрипт был неактивен, а при вводе команды активировался?

xxNecromasterYxx

Новичок
Автор темы
8
1
Как в этом коде сделать так, чтобы скрипт активировался только по команде /acchas?
Lua:
local c_acchas = false
local hi = "Deleysov = molodec"

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
   
   
    sampAddChatMessage("[AutoCchas] script loaded", 0xFFFFFF)
    sampAddChatMessage("Deleysov - molodec", 0xFFFFFF)  
    sampRegisterChatCommand("acchas", c_acchas)
    end
   
local sampev = require('lib.samp.events')

local c_acchas = false  

function c_acchas (arg)
    if c_acchas == false then
        sampAddChatMessage("AutoCchas by necro not activated", 0xFF0000)
    else
        sampAddChatMessage("AutoCchas by necro activated", 0x00CC00)
        if (text:find("/cchas")) then
            lua_threads.create(function()
            wait(1500)
            sampSendChat("/cchas")
            end)
        end
    end
end
 
Решение
Lua:
local state = false

function main()
    while not isSampAvailable() do wait(0) end
    sampAddChatMessage("[AutoCchas] script loaded", 0xFFFFFF)
    sampAddChatMessage("Deleysov - molodec", 0xFFFFFF) 
    sampRegisterChatCommand("acchas", function ()
        state = not state
        sampAddChatMessage(state and 'activated' or 'disabled',-1)
        
    end)   
    while true do
        wait(0)
        
    end
end
function c_acchas()
    if state then
        if text:find("/cchas") then
            lua_thread.create(function()
            wait(1500)
            sampSendChat("/cchas")
            end)
        end
    end
end
так типо?

хромиус)

:steamhappy:
Друг
5,012
3,275
Lua:
local state = false

function main()
    while not isSampAvailable() do wait(0) end
    sampAddChatMessage("[AutoCchas] script loaded", 0xFFFFFF)
    sampAddChatMessage("Deleysov - molodec", 0xFFFFFF) 
    sampRegisterChatCommand("acchas", function ()
        state = not state
        sampAddChatMessage(state and 'activated' or 'disabled',-1)
        
    end)   
    while true do
        wait(0)
        
    end
end
function c_acchas()
    if state then
        if text:find("/cchas") then
            lua_thread.create(function()
            wait(1500)
            sampSendChat("/cchas")
            end)
        end
    end
end
так типо?
 
  • Нравится
Реакции: xxNecromasterYxx