автоотправка

AlexLinkovin

Новичок
Автор темы
10
0
Помогите сделать,что бы если в чате появлялась строка где кто-то пишет "Привет" то у меня автоматически писало в чат "Привет"
 

AlexLinkovin

Новичок
Автор темы
10
0
Как еще сделать активацию?А то делаю вот так вот,а у меня не работает

Lua:
require "lib.moonloader"
require "lib.sampfuncs"
local ev = require 'lib.samp.events'
function main()
  while not isSampAvailable do wait(100) end
  active = 2
  sampRegisterChatCommand("ot", activatecmd)
  while true do
    wait(1)
  end
end

function ev.onServerMessage(color, text)
  if active == 1 then
  if text:find("Привет") then
    sampSendChat("Привет")
    return {color, text}
    active = 2
  end
end
end

function activatecmd()
   if active == 2 then
       active = 1
sampAddChatMessage("Скрипт {00FF00}включен", -1)
   else
       active = 2
sampAddChatMessage("Скрипт {FF0000}выключен", -1)
     end
end
 

James Hawk

Известный
919
217
Как еще сделать активацию?А то делаю вот так вот,а у меня не работает

Lua:
require "lib.moonloader"
require "lib.sampfuncs"
local ev = require 'lib.samp.events'
function main()
  while not isSampAvailable do wait(100) end
  active = 2
  sampRegisterChatCommand("ot", activatecmd)
  while true do
    wait(1)
  end
end

function ev.onServerMessage(color, text)
  if active == 1 then
  if text:find("Привет") then
    sampSendChat("Привет")
    return {color, text}
    active = 2
  end
end
end

function activatecmd()
   if active == 2 then
       active = 1
sampAddChatMessage("Скрипт {00FF00}включен", -1)
   else
       active = 2
sampAddChatMessage("Скрипт {FF0000}выключен", -1)
     end
end
Lua:
sampRegisterChatCommand("команда", function()
        state = not state
        if state then
           sampAddChatMessage("Скрипт {00FF00}включен", -1)
        else
           sampAddChatMessage("Скрипт {FF0000}выключен", -1)
        end
end)
 
  • Нравится
Реакции: xdswd

trefa

Известный
Всефорумный модератор
2,097
1,229
Lua:
sampRegisterChatCommand("команда", function()
        state = not state
        if state then
           sampAddChatMessage("Скрипт {00FF00}включен", -1)
        else
           sampAddChatMessage("Скрипт {FF0000}выключен", -1)
        end
end)
Lua:
sampAddChatMessage("Скрипт "..(state and  "{00FF00}включен" or "{FF0000}выключен"), -1)