local ____lualib = require("lualib_bundle") local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries local ____exports = {} local ____player_info = require("player_info") local PlayerInfo = ____player_info.PlayerInfo local ____server_config = require("server_config") local SERVER_CONFIG = ____server_config.SERVER_CONFIG local ____api_helper = require("api_helper") local setApiHeaders = ____api_helper.setApiHeaders --- Ключ — sound_id (без префикса chat_wheel_sound_) ____exports.CHAT_WHEEL_SOUND_GRANT_META = { agent_gabena = {name = "Агент Габена", sound = "agent_gabena", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, cat_shnapy = {name = "Шни шна...", sound = "cat_shnapy", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex", video = "file://{images}/custom_game/cat_shnapy.webm"}, get_out = {name = "GET OUT", sound = "get_out", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, ura_pobeda = {name = "Ура победа", sound = "ura_pobeda", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, byd_dobr_idi = {name = "Будь добр, иди..", sound = "byd_dobr_idi", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, jump = {name = "Прыгай дура!", sound = "jump", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex", video = "file://{images}/custom_game/jump.webm"}, oi_tak_nravitsa = {name = "Ой, так нравится", sound = "oi_tak_nravitsa", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex", video = "file://{images}/custom_game/oi_tak_nravitsa.webm"}, ne_ponimaiu_karina_strimersha_slozhno_slozhno = {name = "Ничего не понимаю (Карина, «сложно-сложно»)", sound = "ne_ponimaiu_karina_strimersha_slozhno_slozhno", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex", video = "file://{images}/custom_game/ne_ponimaiu_karina_strimersha_slozhno_slozhno.webm"}, kitty_flex = {name = "Китти флекс", sound = "kitty_flex", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex", video = "file://{images}/custom_game/kitty_flex.webm"}, eblo_razraba = {name = "Ебло разработчика", sound = "eblo_razraba", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex", video = "file://{images}/custom_game/eblo_razraba.webm"}, kuda = {name = "Куда", sound = "kuda", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, bruh = {name = "Bruh", sound = "bruh", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, shizofreniya = {name = "Шизофрения", sound = "shizofreniya", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, vot_eto_povorot = {name = "Вот это поворот", sound = "vot_eto_povorot", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, fbi_open_up = {name = "FBI open up", sound = "fbi_open_up", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, nepravilno_poprobuy_esche_raz = {name = "Неправильно, попробуй ещё раз", sound = "nepravilno_poprobuy_esche_raz", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, dobro_pozhalovat_na_server_shizofreniya = {name = "Добро пожаловать на сервер шизофрении", sound = "dobro_pozhalovat_na_server_shizofreniya", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, nya = {name = "Ня", sound = "nya", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, na_nas_napali = {name = "На нас напали", sound = "na_nas_napali", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, murlok = {name = "Мурлок", sound = "murlok", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, kak_zhit_to_a = {name = "Как жить-то а", sound = "kak_zhit_to_a", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex"}, zaika = {name = "Зайка", sound = "zaika", icon = "s2r://panorama/images/chat_wheel/chat_wheel_icon_png.vtex", video = "file://{images}/custom_game/zaika.webm"} } --- Webm для чата, если в sounds_wheel нет поля video (бэкенд/API отрезал или старые записи). -- Ключ — имя звукового события (поле sound в колесе / invasion_sounds). function ____exports.getChatWheelVideoPathForSound(self, sound) if not sound or sound == "" then return nil end for ____, ____value in ipairs(__TS__ObjectEntries(____exports.CHAT_WHEEL_SOUND_GRANT_META)) do local id = ____value[1] local meta = ____value[2] local key = meta.sound and meta.sound ~= "" and meta.sound or id if key == sound or id == sound then local v = meta.video or meta.video_path if v and #v > 0 then return v end end end return nil end local function saveSoundsWheelToServer(self, playerId, soundsWheel) local steamId = PlayerResource:GetSteamAccountID(playerId) if not steamId then return end local request = CreateHTTPRequest( "PUT", ((SERVER_CONFIG.API_URL .. "/player/") .. tostring(steamId)) .. "/sounds_wheel" ) setApiHeaders(nil, request) request:SetHTTPRequestRawPostBody( "application/json", json.encode({sounds_wheel = soundsWheel}) ) request:Send(function(result) if result.StatusCode >= 200 and result.StatusCode < 300 then print("[CHAT_WHEEL_GRANT] sounds_wheel сохранён для игрока " .. tostring(playerId)) else print("[CHAT_WHEEL_GRANT] Ошибка сохранения sounds_wheel: StatusCode=" .. tostring(result.StatusCode)) end end) end --- Выдать звук чат-колеса (Battle Pass / акция); валюту не списывает. function ____exports.grantChatWheelSoundFromBattlePass(self, playerId, soundId) local meta = ____exports.CHAT_WHEEL_SOUND_GRANT_META[soundId] if not meta then print(("[CHAT_WHEEL_GRANT] Нет метаданных для sound_id=" .. soundId) .. ", используем fallback") end local playerInfoData = PlayerInfo:GetPlayerInfo(playerId) if not playerInfoData then playerInfoData = {} end local soundsWheel = playerInfoData.sounds_wheel or ({}) if soundsWheel[soundId] then print((("[CHAT_WHEEL_GRANT] Звук " .. soundId) .. " уже есть у игрока ") .. tostring(playerId)) return end if not playerInfoData.sounds_wheel then playerInfoData.sounds_wheel = {} end local soundToSave = meta and meta.sound and meta.sound ~= "" and meta.sound or soundId local webm = meta and meta.video or meta and meta.video_path playerInfoData.sounds_wheel[soundId] = { name = meta and meta.name or soundId, type = "sound", sellPrice = 0, sound = soundToSave, icon = meta and meta.icon, video = webm, video_path = webm } PlayerInfo:UpdatePlayerInfo(playerId, playerInfoData) saveSoundsWheelToServer(nil, playerId, playerInfoData.sounds_wheel) local storeModule = require("store_manager") storeModule.StoreManager:getInstance():registerChatWheelSoundFromBattlePass(playerId, soundId) print((("[CHAT_WHEEL_GRANT] Выдан звук " .. soundId) .. " игроку ") .. tostring(playerId)) end return ____exports