Remove all ammo from gun

I was wondering if I could give the player a gun with no ammo in it, and force them to acquire bullets little by little via pickups.

ply:Give(“weapon_pistol”)
ply:SetAmmo( number ammoCount, ammoType )

I tried the following line in the PlayerLoadout hook, but it didn’t seem to change the given ammo amount;

[lua]
ply:Give(“fas2_ragingbull”)
ply:SetAmmo(0, “fas2_ammo_454casull”)
[/lua]

Are you sure that’s the correct ammo type for the gun.

I looked up a list for the addon, and I’m almost absolutely sure.

It’s because the weapon probably has DefaultClip set, which gives them the ammo on its own.

You can do this:


timer.Simple( 0, function( ) if IsValid( ply ) then ply:SetAmmo( 0, "x" ) end end )

Or, you could do this in something like InitPostEntity:


weapons.GetStored( "weapon" ).DefaultClip = 0

Adding this line;

[lua]
timer.Simple( 1, function() if IsValid( ply ) then ply:SetAmmo( 0, “fas2_ammo_454casull” ) end end )[/lua]

doesn’t work. So either fa:s 2 works differently from normal source engine sweps, or there’s something wrong with the command.

However, when I give the player a pistol and set their ammo for that;
[lua]
ply:Give(“weapon_pistol”)
timer.Simple( 5, function() if IsValid( ply ) then ply:SetAmmo( 100, “pistol” ) end ply:PrintMessage(3, “run”) end )
[/lua]
then it does set their reserve ammo to the specified value. However, I want it to empty their gun’s clip as well. Is that possible?

Would changing the default ammo in the actual swep code not work for your purposes?

Do what Kogitsune said if you want the weapons to never have default ammo, otherwise get the players active weapon and call

Weapon:SetClip1

Thanks, that’s exactly what I wanted. However, I don’t know how to get these methods to work with FA:S 2.0.

[editline]17th March 2015[/editline]

How would I extend the FA:S 2 revolver swep and make modifications of it? Is this code all that’s necessary;

[lua]SWEP.Base = “fas2_ragingbull”
SWEP.Primary.DefaultClip = 0[/lua]

Or is there something else I have to do?

Bump. I’m still having problems with this.

fas2_ammo_454casull is the name of the entity which gives the ammo, you are looking for the ammo name. You can find this by opening the shared.lua of the weapon and looking for ‘SWEP.Primary.Ammo’.

I looked at the source for the raging bull and found this;
[lua]
SWEP.Primary.Ammo = “.454 Casull”
[/lua]

So that must be the primary ammo type. What puzzles me is why it’s not the same as the ammo entity name, like most source weapons are.

[editline]8th April 2015[/editline]

Also, do you know how I could create my own version of the raging bull that starts with an empty clip?

[editline]8th April 2015[/editline]

My main question from the OP has been pretty much answered by now, so I’ll make a different thread for my current issue.