У меня есть 2 скрипта. Как сделать чтобы при secondary attack (Т.е смене hold type на revolver) приближало камеру вперед, типа прицеливание.
```lua
if CLIENT then
    -------------------------------------------------------------------
    -- FirstPersonView Module
    -- Provides a precise first-person camera positioned at the player's head.
    -------------------------------------------------------------------
    -- Define the FirstPersonView table
    local FirstPersonView = {
        -- Configuration table with default values. These can be overridden via
        -- console variables (ConVars) for dynamic configuration.
        config = {
            headBoneNames = {
                "ValveBiped.Bip01_Head1", -- Priority-ordered list of head bone names
                "ValveBiped.Bip01_Neck1",
                "ValveBiped.Bip01_EyeLeft",
                "ValveBiped.Bip01_EyeRight",
                "ValveBiped.Bip01_Mouth"
            },
            cameraOffset = Vector(0, 0, 0), -- Default camera offset (modifiable via ConVar)
            drawLocalPlayer = true, -- Whether to draw the local player model in first-person
            spectatorTeam = nil, -- Spectator team identifier (to be set during initialization)
            notifyOnError = true, -- Whether to notify the player on errors
            cameraCollision = true, -- Whether to enable camera collision detection
            maxCameraDistance = 60, -- Maximum camera distance to prevent clipping
        },
        -- Table to cache head bone indices for the local player
        headBoneIndices = {},
        -- Flag to ensure single initialization
        initialized = false,
        -- Rate limiter for error notifications to prevent spam
        errorRateLimiter = {
            lastErrorTime = 0,
            cooldown = 5, -- seconds
        },
    }

    ---------------------------------------------------
    -- Utility Functions
    ---------------------------------------------------
    -- Utility function to log messages with a prefix
    local function Log(message, isError)
        if isError then
            if FirstPersonView.config.notifyOnError then chat.AddText(Color(255, 0, 0), "[FirstPersonView] " .. message) end
            print("[FirstPersonView] " .. message)
        else
            print("[FirstPersonView] " .. message)
        end
    end

    -- Utility function to check and update the rate limiter
    local function CanNotifyError()
        local currentTime = CurTime()
        if currentTime - FirstPersonView.errorRateLimiter.lastErrorTime >= FirstPersonView.errorRateLimiter.cooldown then
            FirstPersonView.errorRateLimiter.lastErrorTime = currentTime
            return true
        end
        return false
    end

    ---------------------------------------------------
    -- Configuration Loading and Management
    ---------------------------------------------------
    -- Function to load and apply camera offset from ConVar
    local function LoadCameraOffset()
        local offsetX = GetConVar("fvp_camera_offset_x"):GetFloat()
        local offsetY = GetConVar("fvp_camera_offset_y"):GetFloat()
        local offsetZ = GetConVar("fvp_camera_offset_z"):GetFloat()
        FirstPersonView.config.cameraOffset = Vector(offsetX, offsetY, offsetZ)
    end

    -- Function to load head bone names from ConVar (comma-separated)
    local function LoadHeadBoneNames()
        local boneNamesString = GetConVar("fvp_head_bone_names"):GetString()
        local boneNamesRaw = string.Split(boneNamesString, ",")
        -- Trim whitespace and ensure uniqueness using a temporary table
        local uniqueBoneSet = {}
        local uniqueBoneList = {}
        for _, name in ipairs(boneNamesRaw) do
            local trimmed = string.Trim(name)
            if trimmed ~= "" and not uniqueBoneSet[trimmed] then
                table.insert(uniqueBoneList, trimmed)
                uniqueBoneSet[trimmed] = true
            end
        end

        FirstPersonView.config.headBoneNames = uniqueBoneList
    end

    -- Function to load spectator team from ConVar
    local function LoadSpectatorTeam()
        -- Attempt to fetch TEAM_SPECTATOR safely
        local spectatorTeam = GetConVar("fvp_spectator_team"):GetInt()
        if spectatorTeam <= 0 then
            -- Fallback to default if invalid
            spectatorTeam = TEAM_SPECTATOR or 8
        end

        FirstPersonView.config.spectatorTeam = spectatorTeam
    end

    -- Function to initialize ConVars for dynamic configuration
    local function InitializeConVars()
        CreateClientConVar("fvp_camera_offset_x", "0", true, false, "FirstPersonView: Camera offset X (forward/backward)")
        CreateClientConVar("fvp_camera_offset_y", "0", true, false, "FirstPersonView: Camera offset Y (left/right)")
        CreateClientConVar("fvp_camera_offset_z", "0", true, false, "FirstPersonView: Camera offset Z (up/down)")
        CreateClientConVar("fvp_head_bone_names", "ValveBiped.Bip01_Head1,ValveBiped.Bip01_Neck1,ValveBiped.Bip01_EyeLeft,ValveBiped.Bip01_EyeRight,ValveBiped.Bip01_Mouth", true, false, "FirstPersonView: Comma-separated list of head bone names")
        CreateClientConVar("fvp_spectator_team", tostring(TEAM_SPECTATOR or 8), true, false, "FirstPersonView: Spectator team identifier")
    end

    -- Function to refresh configuration from ConVars
    local function RefreshConfig()
        LoadCameraOffset()
        LoadHeadBoneNames()
        LoadSpectatorTeam()
    end

    -- Hook to watch for ConVar changes and refresh configuration accordingly
    local function SetupConVarChangeHooks()
        -- Camera Offset Changes
        cvars.AddChangeCallback("fvp_camera_offset_x", LoadCameraOffset, "FirstPersonView_CameraOffsetX")
        cvars.AddChangeCallback("fvp_camera_offset_y", LoadCameraOffset, "FirstPersonView_CameraOffsetY")
        cvars.AddChangeCallback("fvp_camera_offset_z", LoadCameraOffset, "FirstPersonView_CameraOffsetZ")
        -- Head Bone Names Change
        cvars.AddChangeCallback("fvp_head_bone_names", LoadHeadBoneNames, "FirstPersonView_HeadBoneNames")
        -- Spectator Team Change
        cvars.AddChangeCallback("fvp_spectator_team", LoadSpectatorTeam, "FirstPersonView_SpectatorTeam")
    end

    ---------------------------------------------------
    -- Bone Caching
    ---------------------------------------------------
    -- Function to cache head bone indices for the local player
    function FirstPersonView:CacheHeadBones()
        local ply = LocalPlayer()
        if not IsValid(ply) then
            if CanNotifyError() then Log("Local player is not valid. Cannot cache head bones.", true) end
            return
        end

        local model = ply:GetModel()
        if not model or model == "" then
            if CanNotifyError() then Log("Local player's model is invalid. Cannot cache head bones.", true) end
            return
        end

        -- Clear existing cached bones
        table.Empty(self.headBoneIndices)
        -- Iterate through the list of possible head bone names and cache all found bones
        for _, boneName in ipairs(self.config.headBoneNames) do
            local boneIndex = ply:LookupBone(boneName)
            if boneIndex then
                table.insert(self.headBoneIndices, boneIndex)
                -- Optional: Uncomment the following line to reduce console spam
                -- Log("Cached head bone '" .. boneName .. "' (Index: " .. tostring(boneIndex) .. ") for model '" .. model .. "'.", false)
            end
        end

        -- If no head bones found, log warning with rate limiting
        if #self.headBoneIndices == 0 and CanNotifyError() then Log("Warning: No valid head bones found for model '" .. model .. "'. Expected bones: " .. table.concat(self.config.headBoneNames, ", "), true) end
    end

    ---------------------------------------------------
    -- Camera Positioning
    ---------------------------------------------------
    -- Function to get the head position for the local player
    function FirstPersonView:GetHeadPosition()
        local ply = LocalPlayer()
        if not IsValid(ply) then return nil end
        if #self.headBoneIndices == 0 then
            -- Attempt to cache head bones if not already cached
            self:CacheHeadBones()
            if #self.headBoneIndices == 0 then
                -- Fallback to eye position if head bones not found
                Log("Using eye position as fallback for camera.", true)
                return ply:EyePos()
            end
        end

        -- Use the first valid head bone position
        local boneIndex = self.headBoneIndices[1]
        local bonePos = ply:GetBonePosition(boneIndex)
        if bonePos then
            return bonePos
        else
            Log("Failed to get position for head bone index " .. tostring(boneIndex) .. ". Using eye position.", true)
            return ply:EyePos()
        end
    end

    -- Variable to store the current view
    local currentView = {
        origin = Vector(0, 0, 0),
        angles = Angle(0, 0, 0),
        fov = 0,
        drawviewer = false,
    }

    -- Hook to calculate and set the camera view
    function FirstPersonView:CalcView(ply, pos, angles, fov)
        if not IsValid(ply) then return end
        if ply:Team() == self.config.spectatorTeam then return end
        local headPos = self:GetHeadPosition()
        if not headPos then return end
        -- Use the player's actual view angles to ensure camera aligns with player's view
        local playerAngles = ply:EyeAngles()
        -- Calculate the desired camera position based on the head position and camera offset
        local desiredCameraPos = headPos + playerAngles:Forward() * self.config.cameraOffset.x + playerAngles:Right() * self.config.cameraOffset.y + playerAngles:Up() * self.config.cameraOffset.z
        -- Implement camera collision detection to prevent clipping
        if self.config.cameraCollision then
            local trace = {}
            trace.start = headPos
            trace.endpos = desiredCameraPos
            trace.filter = ply
            trace.mask = MASK_VISIBLE_AND_NPCS
            local tr = util.TraceLine(trace)
            if tr.Hit then
                local distance = tr.HitPos:Distance(headPos)
                if distance < self.config.maxCameraDistance then
                    desiredCameraPos = tr.HitPos
                else
                    -- Limit the camera distance
                    desiredCameraPos = headPos + playerAngles:Forward() * self.config.maxCameraDistance + playerAngles:Right() * self.config.cameraOffset.y + playerAngles:Up() * self.config.cameraOffset.z
                end
            end
        end

        -- Directly set the camera position and angles without smoothing
        currentView.origin = desiredCameraPos
        currentView.angles = playerAngles
        currentView.fov = fov
        currentView.drawviewer = self.config.drawLocalPlayer
        return currentView
    end

    ---------------------------------------------------
    -- Local Player Model Rendering
    ---------------------------------------------------
    -- Function to determine whether to draw the local player model
    function FirstPersonView:ShouldDrawLocalPlayer()
        local ply = LocalPlayer()
        if not IsValid(ply) then return true end
        -- Do not draw the player model if in spectator mode
        if ply:Team() == self.config.spectatorTeam then return false end
        return self.config.drawLocalPlayer
    end

    ---------------------------------------------------
    -- Bone Manipulation for Head Hiding
    ---------------------------------------------------
    -- Store original bone scales to restore after manipulation
    FirstPersonView.originalBoneScales = {}
    -- Function to hide the player's head bones
    function FirstPersonView:HideHeadBones()
        local ply = LocalPlayer()
        if not IsValid(ply) then return end
        if #self.headBoneIndices == 0 then return end
        for _, boneIndex in ipairs(self.headBoneIndices) do
            -- Store the original scale if not already stored
            if not self.originalBoneScales[boneIndex] then
                local originalScale = ply:GetManipulateBoneScale(boneIndex)
                if originalScale then
                    self.originalBoneScales[boneIndex] = originalScale
                else
                    self.originalBoneScales[boneIndex] = Vector(1, 1, 1)
                end
            end

            -- Hide the bone by setting its scale to zero
            ply:ManipulateBoneScale(boneIndex, Vector(0, 0, 0))
        end
    end

    -- Function to restore the player's head bones
    function FirstPersonView:RestoreHeadBones()
        local ply = LocalPlayer()
        if not IsValid(ply) then return end
        if #self.headBoneIndices == 0 then return end
        for _, boneIndex in ipairs(self.headBoneIndices) do
            if self.originalBoneScales[boneIndex] then
                ply:ManipulateBoneScale(boneIndex, self.originalBoneScales[boneIndex])
                self.originalBoneScales[boneIndex] = nil
            else
                -- If original scale wasn't stored, ensure it's visible
                ply:ManipulateBoneScale(boneIndex, Vector(1, 1, 1))
            end
        end
    end

    -- Hook to handle pre-player draw
    function FirstPersonView:PrePlayerDraw(ply)
        if ply ~= LocalPlayer() then return end
        self:HideHeadBones()
    end

    -- Hook to handle post-player draw
    function FirstPersonView:PostPlayerDraw(ply)
        if ply ~= LocalPlayer() then return end
        self:RestoreHeadBones()
    end

    ---------------------------------------------------
    -- Event Handlers
    ---------------------------------------------------
    -- Hook to handle player model changes
    function FirstPersonView:OnPlayerSetModel(ply)
        if ply ~= LocalPlayer() then return end
        self:CacheHeadBones()
    end

    -- Hook to handle player spawn events
    function FirstPersonView:OnPlayerSpawn(ply)
        if ply ~= LocalPlayer() then return end
        -- Delay caching to ensure the model is fully loaded
        timer.Simple(0.5, function() if IsValid(ply) then self:CacheHeadBones() end end)
    end

    -- Hook to handle player disconnection and clean up cache
    function FirstPersonView:OnPlayerDisconnected(ply)
        if ply ~= LocalPlayer() then return end
        -- Clear cached bone indices and restore bone scales if necessary
        if #self.headBoneIndices > 0 then
            self:RestoreHeadBones()
            table.Empty(self.headBoneIndices)
            Log("Cleared cached head bones due to player disconnection.", false)
        end
    end

    ---------------------------------------------------
    -- Initialization and Cleanup
    ---------------------------------------------------
    -- Function to clean up all hooks and cached data
    function FirstPersonView:RemoveHooks()
        hook.Remove("CalcView", "FirstPersonView_CalcView")
        hook.Remove("ShouldDrawLocalPlayer", "FirstPersonView_ShouldDrawLocalPlayer")
        hook.Remove("PlayerSetModel", "FirstPersonView_PlayerSetModel")
        hook.Remove("PlayerSpawn", "FirstPersonView_PlayerSpawn")
        hook.Remove("PrePlayerDraw", "FirstPersonView_PrePlayerDraw")
        hook.Remove("PostPlayerDraw", "FirstPersonView_PostPlayerDraw")
        hook.Remove("ShutDown", "FirstPersonView_ShutDown")
        hook.Remove("PlayerDisconnected", "FirstPersonView_PlayerDisconnected")
        -- Restore bone scales if hidden
        self:RestoreHeadBones()
        -- Clear cached bone indices
        table.Empty(self.headBoneIndices)
        self.initialized = false
        Log("All hooks removed and caches cleared.", false)
    end

    -- Initialization function
    function FirstPersonView:Initialize()
        if self.initialized then
            Log("Initialization skipped: already initialized.", false)
            return
        end

        self.initialized = true
        InitializeConVars()
        RefreshConfig()
        SetupConVarChangeHooks()
        -- Cache head bones for the local player
        self:CacheHeadBones()
        -- Register hooks
        hook.Add("CalcView", "FirstPersonView_CalcView", function(ply, pos, angles, fov) return FirstPersonView:CalcView(ply, pos, angles, fov) end)
        hook.Add("ShouldDrawLocalPlayer", "FirstPersonView_ShouldDrawLocalPlayer", function() return FirstPersonView:ShouldDrawLocalPlayer() end)
        hook.Add("PlayerSetModel", "FirstPersonView_PlayerSetModel", function(ply) FirstPersonView:OnPlayerSetModel(ply) end)
        hook.Add("PlayerSpawn", "FirstPersonView_PlayerSpawn", function(ply) FirstPersonView:OnPlayerSpawn(ply) end)
        hook.Add("PrePlayerDraw", "FirstPersonView_PrePlayerDraw", function(ply) FirstPersonView:PrePlayerDraw(ply) end)
        hook.Add("PostPlayerDraw", "FirstPersonView_PostPlayerDraw", function(ply) FirstPersonView:PostPlayerDraw(ply) end)
        hook.Add("PlayerDisconnected", "FirstPersonView_PlayerDisconnected", function(ply) FirstPersonView:OnPlayerDisconnected(ply) end)
        hook.Add("ShutDown", "FirstPersonView_ShutDown", function() FirstPersonView:RemoveHooks() end)
        Log("FirstPersonView initialized successfully.", false)
    end

    ---------------------------------------------------
    -- Start Initialization if Not Already Initialized
    ---------------------------------------------------
    -- Prevent multiple instances by checking if already initialized
    if not FirstPersonView.initialized then
        -- Delay initialization to ensure teams and other dependencies are loaded
        hook.Add("InitPostEntity", "FirstPersonView_Initialize", function() FirstPersonView:Initialize() end)
    end
    -------------------------------------------------------------------
    -- End of FirstPersonView Module
    -------------------------------------------------------------------
end
```
```lua
-- Файл: lua/weapons/custom_weapon.lua
SWEP.PrintName = "Кастомное Оружие"
SWEP.Author = "ВашеИмя"
SWEP.Instructions = "Левый клик для стрельбы."
SWEP.Spawnable = true
SWEP.AdminOnly = false
-- Настройка боеприпасов
SWEP.Primary.ClipSize = 7 -- Размер магазина
SWEP.Primary.DefaultClip = 8 -- 7 в магазине + 1 в патронник
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "Pistol" -- Тип боеприпасов
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
-- Отключаем стандартные руки и ViewModel
SWEP.UseHands = false
SWEP.ViewModel = "" -- Оставьте пустым для отключения
SWEP.ViewModelFOV = 54
-- Указываем модель для мира (что видят другие игроки)
SWEP.WorldModel = "models/deadfall/weapons/fb wz,35 vis.mdl" -- Укажите правильный путь к модели
-- Установка типа хватки
function SWEP:Initialize()
    self:SetHoldType("pistol") -- Устанавливаем начальный тип хватки
    
    if CLIENT then
        self.ShowAmmoStartTime = 0 -- Время начала отображения текста
        self.ShowAmmoDuration = 3 -- Время, в течение которого текст полностью видим (без учета фейдов)
        self.FadeTime = 1 -- Время фейда (плавного появления и исчезновения)
        self.CurrentHoldType = "pistol" -- Переменная для отслеживания текущего типа хватки
    end
end

-- Создание клиентской модели оружия
if CLIENT then
    function SWEP:CreateWeaponModel()
        if IsValid(self.WeaponModel) then return end
        self.WeaponModel = ClientsideModel(self.WorldModel)
        if IsValid(self.WeaponModel) then
            self.WeaponModel:SetNoDraw(true)
        else
            print("Ошибка: Не удалось создать клиентскую модель оружия по пути " .. self.WorldModel)
        end
    end

    -- Обновление позиции и углов модели оружия
    function SWEP:UpdateWeaponModel()
        if not IsValid(self.WeaponModel) or not IsValid(self:GetOwner()) then return end
        local owner = self:GetOwner()
        local boneIndex = owner:LookupBone("ValveBiped.Bip01_R_Hand") -- Кость правой руки
        if not boneIndex then return end
        local boneMatrix = owner:GetBoneMatrix(boneIndex)
        if not boneMatrix then return end
        local pos, ang = boneMatrix:GetTranslation(), boneMatrix:GetAngles()
        -- Настройка углов поворота для правильного отображения модели
        ang:RotateAroundAxis(ang:Forward(), 10)
        ang:RotateAroundAxis(ang:Right(), 180)
        ang:RotateAroundAxis(ang:Up(), 180)
        -- Настройка позиции относительно кости руки
        pos = pos + ang:Forward() * -1.5 + ang:Right() * -2 + ang:Up() * 2.3
        self.WeaponModel:SetRenderOrigin(pos)
        self.WeaponModel:SetRenderAngles(ang)
    end

    -- Функция Think для отслеживания нажатия клавиши R (перезарядки) и изменения типа хватки
    function SWEP:Think()
        -- Существующая логика отображения патронов при перезарядке
        if self.ShowAmmoStartTime == nil then self.ShowAmmoStartTime = 0 end
        if self:GetOwner():KeyPressed(IN_RELOAD) then
            self.ShowAmmoStartTime = CurTime() -- Начало отображения текста
        end
        
        -- Новая логика для изменения типа хватки при нажатии правой кнопки мыши
        local owner = self:GetOwner()
        if IsValid(owner) then
            if owner:KeyDown(IN_ATTACK2) then -- Проверяем, удерживается ли правая кнопка мыши
                if self.CurrentHoldType ~= "revolver" then
                    self:SetHoldType("revolver") -- Меняем тип хватки на "revolver"
                    self.CurrentHoldType = "revolver" -- Обновляем текущий тип хватки
                end
            else
                if self.CurrentHoldType ~= "pistol" then
                    self:SetHoldType("pistol") -- Возвращаем тип хватки на "pistol"
                    self.CurrentHoldType = "pistol" -- Обновляем текущий тип хватки
                end
            end
        end
        
        -- Существующая логика функции Think
        local currentTime = CurTime()
        local elapsedTime = currentTime - self.ShowAmmoStartTime
        local totalDisplayTime = self.ShowAmmoDuration + 2 * self.FadeTime -- Общее время отображения текста
        if elapsedTime < 0 or elapsedTime > totalDisplayTime then
            return -- Не отображаем текст
        end

        -- Вычисляем альфа-канал для плавного появления и исчезновения
        local alpha = 255
        if elapsedTime < self.FadeTime then
            -- Фаза плавного появления
            alpha = Lerp(elapsedTime / self.FadeTime, 0, 255)
        elseif elapsedTime > (self.ShowAmmoDuration + self.FadeTime) then
            -- Фаза плавного исчезновения
            local fadeOutTime = elapsedTime - (self.ShowAmmoDuration + self.FadeTime)
            alpha = Lerp(fadeOutTime / self.FadeTime, 255, 0)
        else
            alpha = 255 -- Полностью видимый текст
        end

        if not IsValid(self:GetOwner()) then return end
        local owner = self:GetOwner()
        local boneIndex = owner:LookupBone("ValveBiped.Bip01_R_Hand")
        if not boneIndex then return end
        local bonePos, boneAng = owner:GetBonePosition(boneIndex)
        -- Настройка позиции текста относительно руки
        local offset = Vector(0, 10, -5)
        local textPos = bonePos + boneAng:Right() * offset.x + boneAng:Forward() * offset.y + boneAng:Up() * offset.z
        -- Настройка угла поворота текста
        local textAng = boneAng
        textAng:RotateAroundAxis(boneAng:Right(), 90)
        textAng:RotateAroundAxis(boneAng:Up(), 90)
        textAng:RotateAroundAxis(boneAng:Forward(), 0)
        cam.Start3D2D(textPos, textAng, 0.1)
        draw.SimpleText("Патроны: " .. self:Clip1() .. "/" .. owner:GetAmmoCount(self.Primary.Ammo), "DermaLarge", 0, 0, Color(255, 255, 255, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
        cam.End3D2D()
    end

    -- Отрисовка модели оружия в мире и 3D текста с количеством патронов
    function SWEP:DrawWorldModel()
        -- Сначала отрисовываем модель оружия
        if not IsValid(self.WeaponModel) then
            self:CreateWeaponModel()
            if not IsValid(self.WeaponModel) then return end
        end

        if IsValid(self:GetOwner()) then
            self:UpdateWeaponModel()
            self.WeaponModel:DrawModel()
        else
            self:DrawModel()
        end

        -- Затем отрисовываем 3D текст с количеством патронов, если время отображения не истекло
        local currentTime = CurTime()
        local elapsedTime = currentTime - self.ShowAmmoStartTime
        local totalDisplayTime = self.ShowAmmoDuration + 2 * self.FadeTime -- Общее время отображения текста
        if elapsedTime < 0 or elapsedTime > totalDisplayTime then
            return -- Не отображаем текст
        end

        -- Вычисляем альфа-канал для плавного появления и исчезновения
        local alpha = 255
        if elapsedTime < self.FadeTime then
            -- Фаза плавного появления
            alpha = Lerp(elapsedTime / self.FadeTime, 0, 255)
        elseif elapsedTime > (self.ShowAmmoDuration + self.FadeTime) then
            -- Фаза плавного исчезновения
            local fadeOutTime = elapsedTime - (self.ShowAmmoDuration + self.FadeTime)
            alpha = Lerp(fadeOutTime / self.FadeTime, 255, 0)
        else
            alpha = 255 -- Полностью видимый текст
        end

        if not IsValid(self:GetOwner()) then return end
        local owner = self:GetOwner()
        local boneIndex = owner:LookupBone("ValveBiped.Bip01_R_Hand")
        if not boneIndex then return end
        local bonePos, boneAng = owner:GetBonePosition(boneIndex)
        -- Настройка позиции текста относительно руки
        local offset = Vector(0, 10, -5)
        local textPos = bonePos + boneAng:Right() * offset.x + boneAng:Forward() * offset.y + boneAng:Up() * offset.z
        -- Настройка угла поворота текста
        local textAng = boneAng
        textAng:RotateAroundAxis(boneAng:Right(), 90)
        textAng:RotateAroundAxis(boneAng:Up(), 90)
        textAng:RotateAroundAxis(boneAng:Forward(), 0)
        cam.Start3D2D(textPos, textAng, 0.1)
        draw.SimpleText("Патроны: " .. self:Clip1() .. "/" .. owner:GetAmmoCount(self.Primary.Ammo), "DermaLarge", 0, 0, Color(255, 255, 255, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
        cam.End3D2D()
    end

    -- Удаление клиентской модели оружия
    function SWEP:OnRemove()
        if IsValid(self.WeaponModel) then
            self.WeaponModel:Remove()
            self.WeaponModel = nil
        end
    end

    -- Очистка модели при холстере
    function SWEP:Holster()
        if IsValid(self.WeaponModel) then
            self.WeaponModel:Remove()
            self.WeaponModel = nil
        end
        return true
    end
end

-- Деплой оружия
function SWEP:Deploy()
    if CLIENT then self:CreateWeaponModel() end
    self:SendWeaponAnim(ACT_VM_DRAW)
    return true
end

-- Основная логика при первичной атаке (стрельба)
function SWEP:PrimaryAttack()
    if not self:CanPrimaryAttack() then return end
    self:SetNextPrimaryFire(CurTime() + self:GetPrimaryFireDelay())
    local owner = self:GetOwner()
    if not IsValid(owner) then return end
    -- Воспроизвести звуковой эффект
    self:EmitSound("Weapon_Pistol.Single")
    -- Воспроизвести анимацию выстрела
    self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
    owner:SetAnimation(PLAYER_ATTACK1) -- Анимация игрока при выстреле
    -- Уменьшаем количество патронов в магазине
    self:TakePrimaryAmmo(1)
    -- Создать эффект выстрела (Muzzle Flash)
    if CLIENT then
        local vm = owner:GetViewModel()
        if IsValid(vm) then
            local attachmentID = vm:LookupAttachment("1") -- Обычно "1" это muzzle
            local attachment = vm:GetAttachment(attachmentID)
            if attachment then
                local effect = EffectData()
                effect:SetOrigin(attachment.Pos)
                effect:SetAngles(attachment.Ang)
                effect:SetScale(1)
                util.Effect("MuzzleFlash", effect)
            end
        end
    end

    -- Логика выстрела пули со всеми эффектами
    if SERVER then
        local bullet = {}
        bullet.Num = 1
        bullet.Src = owner:GetShootPos() -- Позиция вылета пули
        bullet.Dir = owner:GetAimVector() -- Направление вылета пули
        bullet.Spread = Vector(0, 0, 0) -- Разброс (измените при необходимости)
        bullet.Tracer = 1 -- Частота появления трассеров (1 = каждый выстрел)
        bullet.TracerName = "Tracer" -- Эффект трассера ("Tracer" - стандартный)
        bullet.Force = 5 -- Сила попадания
        bullet.Damage = 10 -- Урон
        bullet.AmmoType = self.Primary.Ammo
        owner:FireBullets(bullet)
    end
end

-- Задержка между выстрелами
function SWEP:GetPrimaryFireDelay()
    return 0.5 -- Задержка между выстрелами в секундах
end

-- Проверка возможности атаки
function SWEP:CanPrimaryAttack()
    if self:Clip1() <= 0 then
        self:EmitSound("Weapon_Pistol.Empty") -- Звук пустого магазина
        self:SetNextPrimaryFire(CurTime() + 0.2) -- Небольшая задержка перед следующим действием
        return false
    end
    return true
end

-- Действие при вторичной атаке
function SWEP:SecondaryAttack()
    -- Если вторичная атака не используется, оставьте пустым
    -- Hold type изменяется динамически в функции Think()
end

-- Функция перезарядки оружия
function SWEP:Reload()
    if self:GetOwner():KeyDown(IN_ATTACK) then -- Не перезаряжаться при атаке
        return
    end

    if self:Clip1() >= self.Primary.ClipSize then -- Магазин полон
        return
    end

    if self:GetOwner():GetAmmoCount(self.Primary.Ammo) <= 0 then -- Нет боеприпасов
        return
    end

    self:DefaultReload(ACT_VM_RELOAD)
    self:EmitSound("Weapon_Pistol.Reload") -- Звук перезарядки
    self:SetNextPrimaryFire(CurTime() + 2) -- Устанавливаем задержку на время перезарядки
    self:GetOwner():SetAnimation(PLAYER_RELOAD) -- Анимация перезарядки для игрока
end
```