Disabling automatic ammunition supply when picking up standard hl2 weapons.

Is there any way to disable automatic ammunition supply when for example picking up a hl2 SMG1? (You get 30 SMG1 ammunition when picking it up)
I have tried almost anything now.

Maybe this is not even a lua related question (maybe its a console command?) but i guess it can be fixed with a function i still don’t know about.

Thanks.

  • Chrik

You could disable picking up a weapon if the player already have one of that kind by using **[Gamemode.PlayerCanPickupWeapon

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.PlayerCanPickupWeapon)**
[lua]
hook.Add(“PlayerCanPickupWeapon”, “uniquenameforpickupweaponhere”, function(pl, wep)
if pl:HasWeapon(wep:GetClass()) then return false end
end)
[/lua]

Disabling just ammo pickup is a bit more trickier

Bit hacky, but I got it to work:

[lua]
hook.Add( “PlayerCanPickupWeapon”, “NoAmmoPickup”, function( ply, wep )

local type = wep:GetPrimaryAmmoType() 
local old = ply:GetAmmoCount( type ) 
timer.Simple( 0.1, function()
    if ValidEntity( wep ) then wep:SetClip1( 0 ) end -- if you give a player a weapon they already have, wep will be null
    ply:SetAmmo( old, type )
end )

end )
[/lua]