How to disable weapon dropping for a certain weapon?

Imagine wanting to prevent people dropping a certain weapon or just any swep, how would I go on about it?
The only thing I read about was that you can disable weapon drop on death but thats not what I am talking bout

The only way other than death that a player can drop a weapon is with either

Player:DropWeapon or

Player:DropNamedWeapon, so the only option (I think) is to detour those functions to only work if you want them to.

So I would have to make every other weapon enabled for dropping except this one specific swep?
I have a huge weapons pack on my server, so I probably wont do that… rip

If you’re using DarkRP, then this could be useful:
http://wiki.darkrp.com/index.php/Hooks/Server/canDropWeapon

You can just make a blacklist, instead.

Sandbox, I know darkrp has a method of doing that

How would I do that?


local PLAYER = FindMetaTable("Player")
local fDropWeapon = PLAYER.DropWeapon

local tBlacklist = {
   weapon_foo = true,
   weapon_blah = true
}

function PLAYER:DropWeapon(pWeapon)
   if (not tBlacklist[pWeapon:GetClass()]) then
      fDropWeapon(self, pWeapon)
   end
end

Same philosophy with DropNamedWeapon.

thx! very helpful