Press Use to Pick up a Weapon

Well, basically, I need a script that enables you to press ‘use’ (e) on a weapon to pick it up. I can’t recall how many maps I’ve played that are very awkward to move around without picking something up that you don’t. I couldn’t script if my life depended on it (well, maybe if my life depended on it), so I would like to ask the public for a script like this. Just pressing use on a weapon to pick it up. It would be especially useful for RP’ing. I have searched Google and www.garrysmod.org but I got nothing. If you have found one, if you could be so kind to post it here, or in a PM or something, it would be greatly appreciated. Thanks you for any help.

I’m pretty sure that weapon pickup is hard coded into Gmod. You could, however, replace the weapons with entities that give a weapon on use, and then disappear.

Hundreds of theese already exists. The problem is that some of them screw with your normal weapon spawning.

[lua]
// RabidToaster is SO frickin cool

// What the hell is this doing clientside?
if ( CLIENT ) then return end

local function PlayerCanPickupWeapon( ply, weap )
if ( CurTime() <= ( ply.UseWeaponSpawn or 0 ) ) then return end
if ( !ply:KeyDown( IN_USE ) ) then return false end
local trace = util.QuickTrace( ply:GetShootPos(), ply:GetAimVector() * 8192, ply )
if ( !trace.Entity || !trace.Entity:IsValid() || trace.Entity != weap ) then
return false
end
end
hook.Add( “PlayerCanPickupWeapon”, “UseWeapon”, PlayerCanPickupWeapon )

local function PlayerSpawn( ply )
ply.UseWeaponSpawn = CurTime()
end
hook.Add( “PlayerSpawn”, “UseWeapon”, PlayerSpawn )
[/lua]
Credits go to RabidToaster

Thank you.

Question: Does this like, actually work (as in does it screw with weapon spawning whatsoever?).

Also is this a server-side script that changes ALL weapons on the server regardless so they can only be picked up using ‘E’? or does this have to be manually imputed into an individual weapons lua?

Thanks =]