Ammocrate v1.1 (The world's best)

Ammocrate v1.1

The Ammocrate is a SENT to help supply ammo to you and your friends. It can hold primary ammo for any weapon. If you’re in need, equip the weapon you want ammo for and hold USE on the crate. Have a bunch of ammo you’re not going to use? Why not store it for your teammates by equipping the appropriate weapon and holding USE briefly on the crate. Want to see if you have enough ammo to survive the next zombie rush? Just tap USE on the crate to see how much ammo it has for your current weapon.

[li]Animation and sound - not just a lame prop[/li][li]Finite ammo for ALL weapons in one crate (plus an admin-only infinite version)[/li][li]Smart behavior[/li][li]Save ammo for later (or friends)[/li][li]Full support for secondary ammo and custom ammo types[/li][li]Variable weight (based on how much ammo is stored)[/li][li]Players’ Ammocrates start with no ammo, but Admins’ start with some[/li][li]Instructions on the side of the Ammocrate itself, to help newbs on your server[/li][li]Well-commented script, for anyone trying to learn Lua[/li][/ul]

Known bugs:
[li]Doesn’t work for SLAMs, since they apparently don’t use ammo[/li][li]Online multiplayer is untested (due to my router slowly dying)[/li][li]The Ammocrate model has no bottom. Nothing I can do about that, sorry.[/li][/ul]

Potential additions for future versions:
[li]A Derma menu for the Ammocrate, once I learn how to work with Derma and can think of a good menu layout.[/li][li]Ammoboxer: A device that lets you put any kind and amount of ammo into a destroyable supply crate.[/li][/ul]

[li]Added full secondary ammo support (including weapons using only secondary ammo)[/li][li]Added support for custom ammo types.[/li][li]Improved the code somewhat.[/li][li]Improved feedback messages.[/li][/ul]

Primary location, hosted by Filefront
Alternate location, hosted by Google Sites
(Feel free to reupload my addon to if you like it.)

Questions, comments, critique, suggestions, praise? I welcome it. Hope you enjoy my first official Gmod release.

:iia: downloading

Add some kind of menu to pickup/store ammo, because you have no control on how much ammo you’re getting or storing.

and custom ammo support, with no need to code modifications

You do, it’s based on how long you hold the USE button. The longer you hold it, the more ammo you get. I’d be willing to do a menu, but I don’t know Derma. Perhaps in the future.

It already HAS custom ammo support. If you have a gun with a custom ammo type, the Ammocrate will start with 0 in store, assume a clip size of 20, and give it a basic name for the text messages (“The Ammocrate has 110 Custom19 rounds left.”). You can store and retrieve it, no problem, no extra code needed.

Well… it’s not working for me

entities/ammocrate_omni/init.lua:169: attempt to concatenate local 'PAmmoName' (a nil value)
entities/ammocrate_omni/init.lua:123: attempt to perform arithmetic on field '?' (a nil value)

That’s strange… I just went back and re-tested everything, and couldn’t recreate those errors… Well, try this modified version and tell me if you still get those errors. If not, I’ll keep the changes for the next patch.

PS) I’ve been away from FP for a long time, what’s with these “Dumb” things at the bottom of nearly every post? Is this the new version of “Smartness”, or something?

No, the rating system is back.

Ah, so there’s someone who hasn’t hit puberty yet who goes and rates every post Dumb? Got it.

Pretty much.

Now it works

but says everything is custom, not pistol, smg, but custom1,custom2…

I know. That was my attempt to exacerbate the problem. So, keeping those changes.

Anyone else have any bugs to fix, features to request (other than a menu, since I still can’t think of a good menu layout), or so forth?

You can find a prop to parent under the ammo crate and color it to solve the third problem.