Weapons having unlimited ammo.

I’ve recently been working on a deathrun server. And as expected I’ve recieved some errors.

On the map deathrun_wood there is a smoke grenade placed on the runners spawn. What I’d like is for the secondary ammo to be is 0. So they only have one smoke grenade to use.

Not sure if this is the code that should be fixed or edited.

SWEP.Secondary.ClipSize         = 1
SWEP.Secondary.DefaultClip         = 1
SWEP.Secondary.Automatic         = false
SWEP.Secondary.Ammo             = "grenade"

If you need any other code then please ask.

Thanks in advance.

Don’t know the bumping rules. But It’s been up for quite some time and has not been replied to so.


The title is kind of confusing what are you wanting to achieve ?

You talk about 3 different things unlimited ammo, errors and having only 1 grenade.

I don’t play much deathrun but are you trying to prevent players from picking up extra grenades ?

Excuse me for the confusing post.

Currently the smoke grenades secondary ammo is set to 9999 and does not change.

I’d like to change that and make it to only 1 secondary grenade and it for not too be unlimited.

In the code it says

SWEP.Secondary.ClipSize 		= 1
SWEP.Secondary.DefaultClip 		= 1

But It’s not correct.

Bump, I really need help. Can’t find any other posts about this!

The issue most likely lies inside your PrimaryAttack function; or helper-functions called or not called therein…

If you’re not using a custom ammo / magazine / inventory system, then you’d need to call: self.TakePrimaryAmmo( 1 ); each time ammo is to be removed. Additionally, if the number of rounds in Ammo1 ( or Clip1… magazine ) is ! > 0 then play a click sound and return…

Here’s how I do the click; yours may just use the Clip1 / Ammo1 function call to determine ammo… I added the else because your logic if not empty then take one… as CLIENT spams, for it to retain proper ammo count, IsFirstTimePredicted is required.

			local _magCount = self.Weapon:GetMagazineAmmoCount( );
			if ( _magCount <= 0 || self:GetIronSights( ) == WEAPON_IRONSIGHTS_LOWERED ) then
				self.Weapon:EmitSound( "Weapon_Pistol.Empty" );
				if ( SERVER || ( CLIENT && IsFirstTimePredicted( ) ) ) then
					self:TakePrimaryAmmo( 1 );