Call of duty style weapon swapping

Can there be an autorun lua that forces you to press (USE) on the weapon in order to pick it up.
And you can only carry a maximum of 2 weapons melee or not?


(User was banned for this post ("Wrong section" - mahalis))

The first is easy and has been asked many times before:

[lua]hook.Add( “PlayerSpawn”, “PickupTimeout”, function( ply )
ply.PickupTimeout = CurTime() + 0.5
end )

hook.Add( “PlayerCanPickupWeapon”, “NoPickup”, function( ply, wep )
if ( ( ply.PickupTimeout or 0 ) < CurTime() ) then return false end
end )

hook.Add( “KeyPress”, “PressUse”, function( ply, key )
if ( key == IN_USE ) then
local tr = ply:GetEyeTrace()
if ( ValidEntity( tr.Entity ) and tr.Entity:IsWeapon() and tr.Entity:GetPos():Distance( ply:GetShootPos() ) < 64 ) then
ply.PickupTimeout = CurTime() + 0.5

		ply:Give( tr.Entity:GetClass() )
		tr.Entity:Remove()
	end
end

end )[/lua]

The second should be easy to do too with PlayerCanPickupWeapon and Player.GetWeapons.

Oh Overv, you have an answer for everything LUA related… :stuck_out_tongue:

thank you very much
and can you please tell me where the other threads for this similar topic are?