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


--[[
    M9K Rainbow Glow – радужное свечение оружия M9K
    Автор: Blackbox Research
    Версия: 1.0
    Клиентский скрипт
--]]

local cv_enabled = CreateClientConVar("m9k_rainbow_enabled", "1", true, false, "Включить радужное свечение оружия M9K")
local cv_scale   = CreateClientConVar("m9k_rainbow_scale", "1", true, false, "Масштаб свечения")
local cv_speed   = CreateClientConVar("m9k_rainbow_speed", "1", true, false, "Скорость смены цвета")
local cv_sat     = CreateClientConVar("m9k_rainbow_sat", "1", true, false, "Насыщенность (0-1)")
local cv_val     = CreateClientConVar("m9k_rainbow_val", "1", true, false, "Яркость (0-1)")

local hue = 0

local function IsM9KWeapon(ent)
    if not IsValid(ent) then return false end
    if not ent:IsWeapon() then return false end
    local class = ent:GetClass()
    if string.find(class, "m9k") then return true end
    if ent.Base and string.find(ent.Base, "m9k") then return true end
    return false
end

hook.Add("Think", "M9K_Rainbow_Update", function()
    if not cv_enabled:GetBool() then return end
    hue = hue + FrameTime() * 60 * cv_speed:GetFloat()
    if hue >= 360 then hue = hue - 360 end
end)

hook.Add("PostDrawOpaqueRenderables", "M9K_Rainbow_Glow", function()
    if not cv_enabled:GetBool() then return end

    local sat = math.Clamp(cv_sat:GetFloat(), 0, 1)
    local val = math.Clamp(cv_val:GetFloat(), 0, 1)
    local col = HSVToColor(hue % 360, sat, val)
    col.a = 255

    local scale = cv_scale:GetFloat()

    for _, ent in ipairs(ents.GetAll()) do
        if IsM9KWeapon(ent) then
            halo.Add({ent}, col, scale, scale, 2, true, true)
        end
    end
end)

concommand.Add("m9k_rainbow_toggle", function()
    RunConsoleCommand("m9k_rainbow_enabled", cv_enabled:GetBool() and "0" or "1")
    print("[M9K Rainbow] Свечение " .. (cv_enabled:GetBool() and "выключено" or "включено"))
end)

concommand.Add("m9k_rainbow_scale", function(_, _, args)
    local v = tonumber(args[1])
    if v then
        RunConsoleCommand("m9k_rainbow_scale", tostring(v))
        print("[M9K Rainbow] Масштаб: " .. v)
    else
        print("Использование: m9k_rainbow_scale <число>")
    end
end)

concommand.Add("m9k_rainbow_speed", function(_, _, args)
    local v = tonumber(args[1])
    if v then
        RunConsoleCommand("m9k_rainbow_speed", tostring(v))
        print("[M9K Rainbow] Скорость: " .. v)
    else
        print("Использование: m9k_rainbow_speed <число>")
    end
end)

print("[M9K Rainbow] Загружен. Команды: m9k_rainbow_toggle, m9k_rainbow_scale <n>, m9k_rainbow_speed <n>")