local sampev = require 'samp.events'
local audio_url = "ССЫЛКУ НА СВОЙ ЗВУК В ФОРМАТЕ .mp3 / .wav"
local triggers = {
"вы тут%??", -- русский
"вы здесь%??",
"вы на месте%??",
"vi tyt%??", -- транслит
"[тt]ут%??", -- частичные совпадения
"[тt]yt%??",
"[тt]ut%??"
}
local function checkTriggers(text)
local processedText = text:lower()
:gsub("ё", "е") -- нормализация буквы ё
:gsub("^{%x+}(.-): ", "") -- удаление цветовых кодов и ника
:gsub("{(%x%x%x%x%x%x)}", "") -- удаление оставшихся цветовых кодов
for _, pattern in ipairs(triggers) do
if processedText:match(pattern:lower()) then
return true
end
end
return false
end
function playNotificationSound()
sampPlaySound(audio_url)
end
-- Обработчик диалогов
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
if checkTriggers(text) then
playNotificationSound()
end
end
-- Обработчик чата
function sampev.onChatMessage(color, text)
if checkTriggers(text) then
playNotificationSound()
end
end