lua:sampregisterchatcommand

sampRegisterChatCommand

Опкод 0B34.
Требования: SA:MP, SAMPFUNCS.

bool result = sampRegisterChatCommand(string cmd, function func)

Регистрирует новую команду чата SA:MP с возможностью задать ей произвольное поведение.

string cmd команда без символа '/'
function func функция-обработчик

bool result результат выполнения

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand("mycmd", cmd_mycmd)
  wait(-1)
end
 
function cmd_mycmd(arg)
  if #arg == 0 then
    print("Command 'mycmd' syntax: /mycmd [something]")
  else
    print("MyCmd: input = " .. arg)
  end
end