хелп с кодом

kee

Известный
Автор темы
192
11
Версия MoonLoader
Другое
Код:
require 'lib.moonloader'
local e = require 'lib.samp.events'
local status = false
function main()
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('rp', function() status = not status printStringNow(status and 'RPChat ~g~ON' or 'RPChat ~r~OFF', 1000) end)
    sampRegisterChatCommand('cc', function() for i = 1, 99 do sampAddChatMessage('', -1) end end)
    wait(-1)
end
function e.onServerMessage(color, text)
    if status then
        sampfuncsLog(string.format('{%s}[%s] %s', tostring(bit.tohex(color)):sub(1, 6), os.date('%X'), text))
        if text:find('((', 1, true) or text:find('))', 1, true) or text:find('SMS:') then
            if tostring(bit.tohex(color)) ~= 'e75480ff' and tostring(bit.tohex(color)) ~= '6699ffaa' then
                addOneOffSound(0, 0, 0, 1138)
                return false
            end
        end
        if not isRolePlay(color, text) then return false end
    end
end
function isRolePlay(c, t)
    return tostring(bit.tohex(c)) == 'e75480ff'
    or tostring(bit.tohex(c)) == 'c2a2daff'
    or tostring(bit.tohex(c)) == '4dc9c9ff'
    or tostring(bit.tohex(c)) == 'BB6666FF'
    or t:find('сказал:', 1, true)
or t:find('крикнул:', 1, true)
or t:find('по телефону:', 1, true)
end
крч вот код и он заключается в том что убирает весь чат в консоль сампфункса чтобы не мешал
есть функция isroleplay в которую вводишь признаки по цвету или по тексту и видя их скрипт выносит все строчки с этими признаками в чат (типа or tostring(bit.tohex(c)) == 'c2a2daff')
мне надо сделать обратную хуйню, так как в этом цвете могут прилетать сообщения по тексту которых мне они не нужны в чате
126134
вот пример
скрипт пропускает в чат сообщение по цвету, но как сделать еще одну функцию, которая сообщения с текстом например "достал из кармана мобильный телефон" будет сразу кидать обратно в сампфункс

версию мунлоадера хз
 

meowprd

Тот самый Котовский
Проверенный
1,280
712
Lua:
require 'lib.moonloader'
local e = require 'lib.samp.events'
local status = false
function main()
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('rp', function() status = not status printStringNow(status and 'RPChat ~g~ON' or 'RPChat ~r~OFF', 1000) end)
    sampRegisterChatCommand('cc', function() for i = 1, 99 do sampAddChatMessage('', -1) end end)
    wait(-1)
end
function e.onServerMessage(color, text)
    if status then
        sampfuncsLog(string.format('{%s}[%s] %s', tostring(bit.tohex(color)):sub(1, 6), os.date('%X'), text))
        if text:find('((', 1, true) or text:find('))', 1, true) or text:find('SMS:') then
            if tostring(bit.tohex(color)) ~= 'e75480ff' and tostring(bit.tohex(color)) ~= '6699ffaa' then
                addOneOffSound(0, 0, 0, 1138)
                return false
            end
        end
        if not isRolePlay(color, text) then return false end
        
        -- Обрати внимание на добавленный кусок кода.
        if text:find("достал из кармана телефон и отправил sms") or
           text:find("ДРУГОЙ ТЕКСТ")
        then
            return false
        end
    end
end
function isRolePlay(c, t)
    return tostring(bit.tohex(c)) == 'e75480ff'
    or tostring(bit.tohex(c)) == 'c2a2daff'
    or tostring(bit.tohex(c)) == '4dc9c9ff'
    or tostring(bit.tohex(c)) == 'BB6666FF'
    or t:find('сказал:', 1, true)
or t:find('крикнул:', 1, true)
or t:find('по телефону:', 1, true)
end
 
  • Нравится
Реакции: kee

kee

Известный
Автор темы
192
11
Lua:
require 'lib.moonloader'
local e = require 'lib.samp.events'
local status = false
function main()
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('rp', function() status = not status printStringNow(status and 'RPChat ~g~ON' or 'RPChat ~r~OFF', 1000) end)
    sampRegisterChatCommand('cc', function() for i = 1, 99 do sampAddChatMessage('', -1) end end)
    wait(-1)
end
function e.onServerMessage(color, text)
    if status then
        sampfuncsLog(string.format('{%s}[%s] %s', tostring(bit.tohex(color)):sub(1, 6), os.date('%X'), text))
        if text:find('((', 1, true) or text:find('))', 1, true) or text:find('SMS:') then
            if tostring(bit.tohex(color)) ~= 'e75480ff' and tostring(bit.tohex(color)) ~= '6699ffaa' then
                addOneOffSound(0, 0, 0, 1138)
                return false
            end
        end
        if not isRolePlay(color, text) then return false end
       
        -- Обрати внимание на добавленный кусок кода.
        if text:find("достал из кармана телефон и отправил sms") or
           text:find("ДРУГОЙ ТЕКСТ")
        then
            return false
        end
    end
end
function isRolePlay(c, t)
    return tostring(bit.tohex(c)) == 'e75480ff'
    or tostring(bit.tohex(c)) == 'c2a2daff'
    or tostring(bit.tohex(c)) == '4dc9c9ff'
    or tostring(bit.tohex(c)) == 'BB6666FF'
    or t:find('сказал:', 1, true)
or t:find('крикнул:', 1, true)
or t:find('по телефону:', 1, true)
end
от души