Here is a hook that I use on my server to restrict access to certain weapons:
hook.Add("PlayerCanPickupWeapon", "sv_hav_jobs_hooks_PlayerCanPickupWeapon", function(ply, weapon)
local weapon_class = weapon:GetClass()
if string.match(weapon_class, "m9k_") and not ply:CanPickupWeapon(weapon_class) and not weapon.eventWep then
if CurTime() > (ply.lastnotif or 0) + 1 then
DarkRP.notify(ply, 1, 5, "Vous ne pouvez pas équiper cette arme dans ce métier !")
ply.lastnotif = CurTime()
end
return false
end
end)
When I don't have Srlion's Hook Library everything works fine, access to certain weapons is restricted. If, on the other hand, I put Srlion's Hook Library, the hook does not seem to exist and access to certain weapons is not restricted.
There is no defined default sorting for default hook library so obviously hook order will be different when using my hook library which can change the undefined default behavior.
Here is a hook that I use on my server to restrict access to certain weapons:
When I don't have Srlion's Hook Library everything works fine, access to certain weapons is restricted. If, on the other hand, I put Srlion's Hook Library, the hook does not seem to exist and access to certain weapons is not restricted.
I don't really see where the problem could come from, maybe it's because PlayerCanPickupWeapon returns true as standard? https://github.com/Facepunch/garrysmod/blob/c3801c10e1aacc4c114d81331f301c57bdcf5a52/garrysmod/gamemodes/base/gamemode/player.lua#L44 This is only a hypothesis, but I have done the test several times, and without Srlion's Hook Library no problem and with Srlion's Hook Library it does not work.