PLUGIN.name = "Server Logs"
PLUGIN.author = "Server"
PLUGIN.description = "Система логирования событий сервера для администраторов"

-- Категории логов
PLUGIN.LOG_CATEGORIES = {
    COMBAT = {
        name = "Боевые действия",
        color = Color(255, 100, 100),
        icon = "⚔"
    },
    ADMIN = {
        name = "Администрирование",
        color = Color(255, 200, 50),
        icon = "⚙"
    },
    ECONOMY = {
        name = "Экономика",
        color = Color(100, 200, 100),
        icon = "💰"
    },
    CHAT = {
        name = "Чат",
        color = Color(150, 150, 255),
        icon = "💬"
    },
    CONNECTION = {
        name = "Подключения",
        color = Color(200, 200, 200),
        icon = "🔌"
    },
    INVENTORY = {
        name = "Инвентарь",
        color = Color(255, 150, 100),
        icon = "🎒"
    },
    VEHICLE = {
        name = "Техника",
        color = Color(100, 150, 255),
        icon = "🚗"
    },
    CHARACTER = {
        name = "Персонажи",
        color = Color(150, 255, 150),
        icon = "👤"
    }
}

-- Типы событий
PLUGIN.LOG_TYPES = {
    -- Боевые
    PLAYER_DEATH = {category = "COMBAT", description = "Смерть игрока"},
    PLAYER_HURT = {category = "COMBAT", description = "Получение урона"},
    NPC_DEATH = {category = "COMBAT", description = "Смерть NPC"},
    
    -- Административные
    ADMIN_COMMAND = {category = "ADMIN", description = "Админ команда"},
    PLAYER_KICK = {category = "ADMIN", description = "Кик игрока"},
    PLAYER_BAN = {category = "ADMIN", description = "Бан игрока"},
    PLAYER_WARN = {category = "ADMIN", description = "Предупреждение"},
    PLAYER_ARREST = {category = "ADMIN", description = "Арест игрока"},
    PLAYER_TIE = {category = "ADMIN", description = "Связывание игрока"},
    HANDCUFF_RESTRAIN = {category = "ADMIN", description = "Надевание наручников"},
    HANDCUFF_UNRESTRAIN = {category = "ADMIN", description = "Снятие наручников"},
    PLAYER_JAIL = {category = "ADMIN", description = "Отправка в тюрьму"},
    PLAYER_RELEASE = {category = "ADMIN", description = "Освобождение из тюрьмы"},
    PLAYER_UNARREST = {category = "ADMIN", description = "Снятие ареста"},
    
    -- Экономика
    MONEY_TRANSACTION = {category = "ECONOMY", description = "Денежная транзакция"},
    ITEM_PURCHASE = {category = "ECONOMY", description = "Покупка предмета"},
    SUPPLY_CHANGE = {category = "ECONOMY", description = "Изменение снабжения"},
    FACTION_SUPPLY_ADD = {category = "ECONOMY", description = "Пополнение снабжения фракции"},
    FACTION_SUPPLY_USE = {category = "ECONOMY", description = "Расход снабжения фракции"},
    VEHICLE_POINTS_ADD = {category = "ECONOMY", description = "Пополнение баллов техники"},
    VEHICLE_POINTS_USE = {category = "ECONOMY", description = "Расход баллов техники"},
    
    -- Чат
    CHAT_MESSAGE = {category = "CHAT", description = "Сообщение в чат"},
    COMMAND_EXECUTED = {category = "CHAT", description = "Выполнена команда"},
    
    -- Подключения
    PLAYER_CONNECT = {category = "CONNECTION", description = "Подключение"},
    PLAYER_DISCONNECT = {category = "CONNECTION", description = "Отключение"},
    PLAYER_SPAWN = {category = "CONNECTION", description = "Спавн игрока"},
    
    -- Инвентарь
    ITEM_PICKUP = {category = "INVENTORY", description = "Поднятие предмета"},
    ITEM_DROP = {category = "INVENTORY", description = "Выброс предмета"},
    ITEM_USE = {category = "INVENTORY", description = "Использование предмета"},
    WEAPON_SPAWN = {category = "INVENTORY", description = "Выдача оружия из арсенала"},
    WEAPON_DONATE = {category = "INVENTORY", description = "Выдача донат оружия"},
    
    -- Техника
    VEHICLE_SPAWN = {category = "VEHICLE", description = "Вызов техники"},
    VEHICLE_RETURN = {category = "VEHICLE", description = "Возврат техники"},
    
    -- Персонажи
    CHARACTER_CREATE = {category = "CHARACTER", description = "Создание персонажа"},
    CHARACTER_DELETE = {category = "CHARACTER", description = "Удаление персонажа"},
    CHARACTER_SWITCH = {category = "CHARACTER", description = "Смена персонажа"},
    
    -- Захват точек
    CAPTURE_START = {category = "COMBAT", description = "Начало захвата точки"},
    CAPTURE_COMPLETE = {category = "COMBAT", description = "Точка захвачена"},
    CAPTURE_LOST = {category = "COMBAT", description = "Точка потеряна"},
    CAPTURE_REWARD = {category = "ECONOMY", description = "Награда за захват"},
    
    -- Отряды
    SQUAD_CREATE = {category = "CHARACTER", description = "Создание отряда"},
    SQUAD_DELETE = {category = "CHARACTER", description = "Расформирование отряда"},
    SQUAD_INVITE = {category = "CHARACTER", description = "Приглашение в отряд"},
    SQUAD_JOIN = {category = "CHARACTER", description = "Вступление в отряд"},
    SQUAD_LEAVE = {category = "CHARACTER", description = "Выход из отряда"},
    SQUAD_KICK = {category = "CHARACTER", description = "Исключение из отряда"}
}

ix.log = ix.log or {}
ix.log.stored = ix.log.stored or {}

-- Конфигурация
ix.config.Add("logMaxEntries", 1000, "Максимальное количество логов в памяти", nil, {
    data = {min = 100, max = 5000},
    category = "server"
})

ix.config.Add("logSaveToFile", true, "Сохранять логи в файл", nil, {
    category = "server"
})

ix.config.Add("logFilePath", "helix_logs", "Папка для сохранения логов", nil, {
    category = "server"
})

-- Локализация команд
if CLIENT then
    ix.lang.AddTable("russian", {
        serverLogsOpened = "Панель логов открыта",
        serverLogsCleared = "Логи сервера очищены",
        serverLogsDisplayed = "Показано логов: %s",
        serverLogsSearchResults = "Найдено логов: %s",
        cmdViewLogs = "Открыть панель логов",
        cmdClearLogs = "Очистить логи",
        cmdLastLogs = "Показать последние логи",
        cmdSearchLogs = "Поиск в логах"
    })
    
    ix.lang.AddTable("english", {
        serverLogsOpened = "Logs panel opened",
        serverLogsCleared = "Server logs cleared",
        serverLogsDisplayed = "Logs displayed: %s",
        serverLogsSearchResults = "Logs found: %s",
        cmdViewLogs = "Open logs panel",
        cmdClearLogs = "Clear logs",
        cmdLastLogs = "Show recent logs",
        cmdSearchLogs = "Search logs"
    })
end

ix.util.Include("cl_plugin.lua")
ix.util.Include("sv_plugin.lua")
