Неактуально как добавить аргумент в команду

EnterName132

Новичок
Автор темы
7
2
Версия MoonLoader
.026-beta
Всем привет, недавно начал изучать луа, пожалуйста, добавьте или напишите в коде так, чтобы он активировался только тогда, когда есть команда и id человека, к примеру /spr 12, заранее спасибо

луа:
require "lib.moonloader"
require "lib.sampfuncs"

local activate = false

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("spr", function() activate = not activate end)
  while true do
    wait(0)
        if activate == true then
            lua_thread.create(function()
                sampSendChat("/sprunk")
                wait(300000)
            end)
        end
  end
end
 

MrDorlik

Известный
972
392
Lua:
require "lib.moonloader"
require "lib.sampfuncs"

local activate = false

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("spr", function(arg)
        id = arg:match('%d+')
        if id and sampIsPlayerConnected(id) then
            activate = not activate
            print('Скрипт ' .. (activate and 'включен' or 'выключен'))
        else
            print('Неверный аргумент')
        end
    end)
    lua_thread.create(function()
        while true do
            if activate then
                sampSendChat("/sprunk")
            end
            wait(300000)
        end
    end)
    while true do
        wait(0)
    end
end
 
  • Нравится
Реакции: EnterName132