Must use "E" to pick up weapons, but can left-click to get one from Weapons menu

Wizey! made this script a while ago for me so that players must press E to pick up weapons. A side effect, though, is that you can no longer left-click on a weapon to spawn it, you have to right-click while looking at the ground.

What I want is to keep that function of having to press E, but I also want to be able to just left-click on one to spawn it.

Here is the script, if you are interested.

[lua]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]

i think i did it… give it a try


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 true end
	local trace = util.QuickTrace( ply:GetShootPos(), ply:GetAimVector() * 8192, ply )
	if ( !trace.Entity || !trace.Entity:IsValid() || trace.Entity != weap ) then
		return true
	end
end
hook.Add( "PlayerCanPickupWeapon", "UseWeapon", PlayerCanPickupWeapon )

local function PlayerSpawn( ply )
	ply.UseWeaponSpawn = CurTime()
end
hook.Add( "PlayerSpawn", "UseWeapon", PlayerSpawn )

Just tested it, doesn’t work. The player automatically picks up any weapon he’s close to/touching, the only difference from the default system is that he can pick it up from about double the distance.

:l
Shit
Give me another chance i swear!

You’re the scripter, haha, I don’t really have a choice :stuck_out_tongue:

Thanks for putting forth effort though, good luck on the next version!

Back to this are we? hmmm i do have that problem with it aswell… Although i never really figured it out, Whats wrong with right clicking it anyway? <.> i still think it works in Give("") lua syntaxes.

I Has done it one more time…
Now im at my laptop so it most possibly will epicly fail again but here you go :buddy:


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 true 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 )

Some people are complaining recently and would just rather be able to left click, while still being able to have a gun on the ground without picking it up.

LAZY PEOPLE!!! Lol, I guess you have a point, but theres also a point to either wait a couple days for someoneto fix it, Or take 3 seconds out of your life and right click it then pick it up! YOU DECIDE!!! :3:

We’re using yours until the other has been made.

It might not even be possible, lol

Everytime you go to give yourself a weapon, count to 3. Then get back to us.

I take 0.6 Seconds, I do coding quickly. Just look straight down Right click then press use right after you press right click, 0.6 seconds!! :v:

-Partly Snipped due to faggotry in next post :v:-

-Snip because I’m a fucking ass-

Go you! You just insulted someone on the internetz! Have a badge! :v:

PS: I should of listened to DM-Gaina about this :ohdear:

then, I snipped. :x

-Snipped due to a wise idea-

Im not going there…

:smug:

It depends where.

Can someone give me a nuke? so i can kill all of you?

PS: Im done with this.

You consult DM-Gaina for every post you make?