Stopping a player from switching weapons?

Is there a hook or function to stop a player from switching weapons?

ply:StripWeapons()
ply:Give (“weapon_name”)

I believe that doesn’t help him at all.

You could do something like this.




function FreezeWeapon(pl)

    pl.FreezeWep = pl:GetActiveWeapon():GetClass()

end

function UnfreezeWeapon(pl)

    pl.FreezeWep = nil

end

function KeepWeaponFrozen()

    for k, v in pairs (player.GetAll()) do
        if v.FreezeWep != nil then
            if v:GetActiveWeapon():GetClass() != v.FreezeWep then
                v:SelectWeapon(v.FreezeWep)
            end
        end
    end

end

hook.Add("Think", "FreezeWeaponHook", KeepWeaponFrozen)