Загрузка данных


-- 1. Создаем элементы меню во вкладке MISC -> User
local main_switch = ui.new_checkbox("MISC", "User", "Активировать функции")

-- Настройки Модель Чейнджера
local model_switch = ui.new_checkbox("MISC", "User", "Включить Model Changer")
local model_side = ui.new_combobox("MISC", "User", "Выбор агента (CS:GO)", {"Sir Bloody Darryl", "Number K", "Special Agent Ava"})

-- Настройки Хитсаундов
local hit_switch = ui.new_checkbox("MISC", "User", "Включить Hit Sound")
local hit_sound_type = ui.new_combobox("MISC", "User", "Выбор звука", {"Skeet", "Neverlose", "Bell", "Metallic"})

-- Таблица со старыми путями моделей в формате .mdl для CS:GO
local csgo_models = {
    ["Sir Bloody Darryl"] = "models/player/custom_player/legacy/tm_professional_varf.mdl",
    ["Number K"] = "models/player/custom_player/legacy/tm_professional_varg.mdl",
    ["Special Agent Ava"] = "models/player/custom_player/legacy/ctm_fbi_variantb.mdl"
}

-- 2. Логика Хитсаунда для CS:GO
client.set_event_callback("player_hurt", function(event)
    if not ui.get(main_switch) or not ui.get(hit_switch) then return end

    local attacker = client.userid_to_entindex(event.attacker)
    local local_player = entity.get_local_player()
    if attacker ~= local_player then return end

    local sound = ui.get(hit_sound_type)
    if sound == "Skeet" then
        client.delay_sound(0, "buttons/arena_switch_press_02.wav")
    elseif sound == "Neverlose" then
        client.delay_sound(0, "physics/metal/paintcan_impact_hard3.wav")
    elseif sound == "Bell" then
        client.delay_sound(0, "training/bell_impact.wav")
    elseif sound == "Metallic" then
        client.delay_sound(0, "physics/metal/metal_solid_impact_bullet2.wav")
    end
end)

-- 3. Логика Модель Чейнджера для CS:GO (через кэширование и замену индекса модели)
client.set_event_callback("pre_render", function()
    if not ui.get(main_switch) or not ui.get(model_switch) then return end

    local local_player = entity.get_local_player()
    if not local_player or not entity.is_alive(local_player) then return end

    local model_name = csgo_models[ui.get(model_side)]
    if not model_name then return end

    -- В CS:GO модель нужно сначала принудительно закэшировать в игре
    local model_index = client.get_model_index(model_name)
    if model_index == nil or model_index == -1 then 
        return 
    end

    -- Устанавливаем модель локальному игроку через m_nModelIndex
    entity.set_prop(local_player, "m_nModelIndex", model_index)
end)

client.log("[Skeet CS:GO] Скрипт успешно запущен!")