Source Engine (Garry's Mod) Ammo System: "Ewwwww!"

I didn’t realize that I’ll run into problems this simple when making SWEPs. There is only a preset amount of ammo types. What do I do?

  • I am making a Deathmatch gamemode.
  • I do NOT want reloading – oldskool, please. This means that each weapon just has one number for the total amount of ammo, and takes its ammo from there.
  • Limit the ammo? (i.e. 200 max) – this is least concern, for now. I presume my ammo SENTs will have to do that…
  • I want my weapons to have their own ammo boxes, ammo names, etc.
  • No secondary fire (I already did that).

I was thinking of assigning each client some variables for the ammo of my weapons. Has this been done before? Is it proper? Or is there another, simpler solution to all of this?

Setting a weapon’s clip size to -1 will make it have no clip, if I remember.

As for the max ammo you could try writing a version of SWEP.EquipAmmo in your base weapon that gives the owner ammo up to the maximum.

Oh. I completely forgot about weapon base. Thanks.

What I meant was coding your own weapon base that implements the features all your weapons have in common (limited ammo, no clip and no reloading, etc). I wouldn’t recommend trying to edit weapon_base, if that’s what you mean.

As for custom ammo types… you can either use a variable on the player and make custom entities change that variable, or simply change the name of the ammo with the Language.Add() like so:

language.Add (“CombineCannon_ammo”, “.50 Ammo”)
language.Add (“AirboatGun_ammo”, “5.56MM Ammo”)
language.Add (“CombineCannon_ammo”, “.50 Ammo”)
language.Add (“StriderMinigun_ammo”, “7.62MM Ammo”)
language.Add (“CombineCannon_ammo”, “.50 Ammo”)
language.Add (“Gravity_ammo”, “4.6MM Ammo”)
language.Add (“CombineCannon_ammo”, “.50 Ammo”)
language.Add (“Battery_ammo”, “9MM Ammo”)
language.Add (“SniperPenetratedRound_ammo”,".45 Ammo")
language.Add (“AlyxGun_ammo” , “5.7MM Ammo”)
language.Add (“SniperRound_ammo”,".376 Steyr Ammo")

Those are just about all the ammo types that are available to use… so just change my values. That section goes in a cl_init.lua since Language.Add() is clientside.

[editline]12th March 2011[/editline]

So wait… you want it to NEVER reload? Like Unreal Tournament or something? If thats the case, set the max clipsize to -1 like Johnny said, and simply just check to see if the ammopool is > 1 before you allow bullets to be shot out.