local keywords = {
"инвайт", "прими в семью", "инв", "инвайт в семью", "инв в фаму", "инвайт в фаму", "инвайт в семью"
}
local command_delay = 5000
function extractPlayerInfoFromMessage(message)
local id = message:match("%d+")
local nick = message:match("[%w_]+")
return id, nick
end
function logToFile(message)
local file = io.open("autofaminvite.log", "a")
if file then
file:write(os.date("[%Y-%m-%d %H:%M:%S] ") .. message .. "\n")
file:close()
end
end
function main()
while true do
wait(0)
for i = 0, 99 do
local result, chat_message = sampGetChatString(i)
if result then
for _, keyword in ipairs(keywords) do
if chat_message:lower():find(keyword:lower()) then
local player_id, player_nick = extractPlayerInfoFromMessage(chat_message)
if player_id or player_nick then
if not player_id and player_nick then
player_id = sampGetPlayerIdByNickname(player_nick)
end
if player_id then
sampSendChat("/faminvite " .. player_id)
logToFile("Отправлена команда: /faminvite " .. player_id .. " (ник: " .. (player_nick or "неизвестно") .. ")")
wait(command_delay)
break
else
logToFile("Не удалось найти ID игрока по нику: " .. (player_nick or "неизвестно"))
end
end
end
end
end
end
end
end