[Помощь] регулярные выражения и запись их в переменную

Tec-9

Новичок
Автор темы
16
1
Версия MoonLoader
.026-beta
Учусь делать регулярные выражения и записывать их в переменную. Захожу на сервер, пишу в чат - "Хорошо"
А оно не работает! По сути дела, должно было вывести мой ник в переменную number и отправить в чат - Nick_Name: Хорошо
Подскажите, что я делаю не так?

Lua:
require 'lib.moonloader'
local sampev = require 'lib.samp.events'

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(200) end

    while true do
        wait(0)

    end
end

function samp.onServerMessage(color, text)
    if text:find('- (%w+_%w+): Хорошо') then
        local number = text:match('- (%w+_%w+): Хорошо')
        sampAddChatMessage(number)
    end
end
 

Tec-9

Новичок
Автор темы
16
1
Не работает

Lua:
require 'lib.moonloader'
local inicfg = require "inicfg"
local sampev = require 'lib.samp.events'

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(200) end

    while true do
        wait(0)

    end
end

function samp.onServerMessage(color, text)
    if text:find('%- (.+): .+: Хорошо') then
        local number = text:match('%- (.+): .+: Хорошо')
        sampAddChatMessage(number)
    end
end
 

RedHolms

Известный
Проверенный
618
360
Не работает

Lua:
require 'lib.moonloader'
local inicfg = require "inicfg"
local sampev = require 'lib.samp.events'

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(200) end

    while true do
        wait(0)

    end
end

function samp.onServerMessage(color, text)
    if text:find('%- (.+): .+: Хорошо') then
        local number = text:match('%- (.+): .+: Хорошо')
        sampAddChatMessage(number)
    end
end
Lua:
require 'lib.moonloader'
local inicfg = require "inicfg"
local sampev = require 'lib.samp.events'

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(200) end

    while true do
        wait(0)

    end
end

function sampev.onServerMessage(color, text)
    if text:match('%- (.+): Хорошо') then
        local number = text:match('%- (.+): Хорошо')
        sampAddChatMessage(number)
    end
end
 
  • Нравится
Реакции: Tec-9

Стэнфорд

Потрачен
1,058
540
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Не работает

Lua:
require 'lib.moonloader'
local inicfg = require "inicfg"
local sampev = require 'lib.samp.events'

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(200) end

    while true do
        wait(0)

    end
end

function samp.onServerMessage(color, text)
    if text:find('%- (.+): .+: Хорошо') then
        local number = text:match('%- (.+): .+: Хорошо')
        sampAddChatMessage(number)
    end
end
За либу samp.events у тебя отвечает переменная sampev , а в функции хука сообщения стоит samp. Вместо samp напиши sampev
 
  • Нравится
Реакции: Tec-9