A toggleable "Use to pickup weapon" using a convar


I need a really simple script that force you to press +use to pickup a weapon…
But with some addition like a Convar to enable it ( like “UseToPickup 1” ) and a ConVar to make that you can’t pickup weapon at all (even if you are pressing use)

Thanks you if you make it!

Up, that could help me a lot!

Again, I’m bumping this thread because I really need it, you know, for making save(not the crappy one, one with a real story) and for personal use on my friend server.

Here’s the code, to block weapon pickup.
It’s convar to disable is weapon_nopickup.

local NoWeaponPickup = CreateConVar( "weapon_nopickup", "0", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_SERVER_CAN_EXECUTE  } )

hook.Add("CanPlayerPickup","Canihazwep", function(ply, weapon)
        if NoWeaponPickup:GetBool() then return end
        if !ply.IsSpawned then ply:Give(weapon) end
	if ply:KeyDown(IN_USE) and ply.IsSpawned then
		return false

hook.Add("PlayerSpawn") function()
        if !ply:IsValid() then return end
	timer.Simple( 5, function()
		ply.IsSpawned = true

Tell me, if it doesn’t work.

I will test it in a second, thanks!

Edit: Doesn’t seem to work :frowning:
Thanks anyways