DESCRIPTION
When a weapon is dropped as a result of a player's death, an ammo box will be dropped alongside the weapon. The weapon entity's extra ammo will be set to 0 and the ammo box will contain what the extra ammo was. If the weapon had 15 in the clip with 75 reserve, the ammo box will have 75 rounds.
It will also record the weapon type (Rifle, Pistol, or Shotgun) and the ammo type. There are CVars (see below) where you can deem if a player can fill their ammo even if the ammo type is different. You can also set this plugin to abide by weapon ammo max so that players cannot pick up more than the default ammo max allowed.
Explanation of allowing or disallowing picking up ammo of the same type if the weapon that dropped it was different - player1 dropped their MP5 rifle and a box of 9mm ammo was dropped from that weapon. If player2 has a glock (which is 9mm) and you have mixed ammo set to "allow" then player2 can pick up that 9mm ammo - if, on the other hand, you have mixed ammo set to "disallow" then player2 cannot pick up that ammo even though their glock uses the same ammo type.
There are three models for the ammo boxes (all included with CS:S, so no need to have anything downloaded to your clients). A model for shotgun ammo, a model for pistol ammo, and a model for rifle ammo. There's also two sound files (also included with CS:S, no need for a download) that fires when players pick up the ammo (you define which one you want to use).
Here are the three models:
[img]http://img402.**************/img402/984/ammofromdead.png[/img]
You can also set to only allow players to drop pistol ammo, or only drop rifle ammo, or be able to drop both. Also, you can set if bots drop ammo or not.
Also, this plugin is Updater capable and a CVar is present (defaulted to off) so you can set whether this plugin gets auto-updated or not (if you have the Updater plugin).
CVars
"sm_afd_gundisolvetype" = "3" min. 0.000000 max. 3.000000
- If sm_afd_destroymode=2, choose dissolve type
0 = Energy
1 = Heavy electrical
2 = Light electrical
3 = Core effect
"sm_afd_gundestroymode" = "2" ( def. "0" ) min. 0.000000 max. 2.000000
- How should the gun model be destroyed?
0 = Do not destroy, leave forever
1 = Just make disappear
2 = Use disolve feature.
"sm_afd_gunlifetime" = "5" ( def. "20" ) min. 0.000000
- How many seconds gun model will stay. Less than 1.0 is disabled.
"sm_afd_disolvetype" = "3" min. 0.000000 max. 3.000000
- If sm_afd_destroymode=2, choose dissolve type
0 = Energy
1 = Heavy electrical
2 = Light electrical
3 = Core effect
"sm_afd_destroymode" = "2" ( def. "0" ) min. 0.000000 max. 2.000000
- How should the ammo model be destroyed?
0 = Do not destroy, leave forever
1 = Just make disappear
2 = Use disolve feature.
"sm_afd_lifetime" = "3" ( def. "20" ) min. 0.000000
- How many seconds ammo model will stay. Less than 1.0 is disabled.
"sm_afd_useupdater" = "0" min. 0.000000 max. 1.000000
- Utilize 'Updater' plugin to auto-update Ammo From Dead when updates are published?
1=yes, 0=no
"sm_afd_playsound" = "1" min. 1.000000 max. 2.000000
- Who should hear the sound?
1 = Only the player
2 = Everyone in the vicinity (like normal item pickups)
"sm_afd_sound" = "1" min. 1.000000 max. 3.000000
- Which sound should we play when ammo is picked up?
1 = cstrike/items/itempickup.wav
2 = hl2/items/ammo_pickup.wav
3 = cstrike/items/ammopickup.wav
"sm_afd_maxammo" = "1" min. 0.000000 max. 1.000000
- Should plugin abide by the weapon's max ammo when picking up dropped ammo? If yes, then the left over ammo will remain on the ground. If all of the ammo is picked up, then the ammo box will disappear.
1=yes, 0=no
"sm_afd_rifles" = "1" min. 0.000000 max. 1.000000
- Drop rifle (shotty, awp, auto, rifle) ammo?
1=yes, 0=no
"sm_afd_pistols" = "1" min. 0.000000 max. 1.000000
- Drop pistol ammo?
1=yes, 0=no
"sm_afd_anymixedammo" = "0" min. 0.000000 max. 1.000000
- If ON, players can refill their pistol ammo by picking up any pistol ammo box, same for shotguns with shotgun ammo box, and the same for rifles (SMG, Rifle, Sniper Rifle, and Machine Gun) with rifle ammo box.
1=ON, 0=OFF
"sm_afd_mixedammo" = "1" min. 0.000000 max. 1.000000
- Allow player to pickup ammo if "ammo type" is the same regardless of if "gun type" is different (UMP vs glock)?
1=yes, 0=no
"sm_afd_botsdrop" = "1" min. 0.000000 max. 1.000000
- Do bots drop ammo?
1=yes, 0=no
"sm_afd_enabled" = "1" min. 0.000000 max. 1.000000
- Am I enabled?
1=yes, 0=no
CREDITS and THANKS
Bacardi for borrowed code from Healthkit from dead plugin
GrO for the tremendous help in testing and suggesting tweaks. GrO was the initial requester and helped out a lot.
Folks on IRC for putting up with my questions
CHANGE LOG
Version 0.2.0.1
- Initial release
Version 0.2.0.2
- Addressed bug where too many times the trie would fail when a player touched the ammo box entity.
Version 0.2.1.0
+ Added dissolve feature for dropped ammo boxes (requested by blue zebra), using Bacardi's method from Healthkit from dead. (new CVars)
Version 0.2.1.1
+ Added dissolve feature for dropped weapons (requested by blue zebra) (new CVars)
Version 0.2.1.2
* Changed the prop type to avoid the mayhem bug and changed to collision alteration to before the prop is spawned.
Version 0.2.1.3
* Fixed error in code that stopped the ammo boxes from working after being touched once.
* Fixed the bug where shotguns could pickup rifle ammo
Version 0.2.1.4
* Updated gamedata with new values for 07/02/12 CS:S update
* Plugin now requires SourceMod 1.4.4 or better
Version 0.2.1.5
* Adjusted values in Gamedata file for 02-05-13 CSS Update.
Version 0.2.1.6 and 0.2.1.7
* Adjusted values in Gamedata file for 04-16-13 CSS Update.
Version 0.2.1.8
* Removed left over debug code
TO DO LIST
mmm - suggest something :)
INSTALLATION
Copy the SMX file to your plugins folder. If you want to compile yourself, you'll need SDKHooks include and Updater include files. The web compiler will not compile the .sp, so you'll need to download the attached .smx.
Also, you need to put the giveammo.txt in your gamedata folder.
A config file will be created when you first launch this plugin - it will be in your cfg\sourcemod folder named plugin.ammo_from_dead.cfg
UPGRADING?
If upgrading to a new version that has new CVars, it's best to backup your old config file and delete it, then let the plugin create a new one for you, then edit that newly created one. This way, you get all of the available configs so you can set the way you want.
1) Is it possible to not override the default limit of overall ammo count? I've noticed that You can pick up ammo boxes all the time, what exceeds the default max ammo amount for each weapon. It would be good to not allow the plugin to exceed the default max ammo amount on pick up and to not allow pick up, when max ammo limit is met.
2) could You make so the ammo box is dropped always at the front of the player, not at random directions?
3) also the entity spawn position seems to be too high (EyePosition), what temporarily lowers the client's view position, when weapon+ammo box is dropped
4) could You make the throw power weaker, to make the ammo box land much closer to the weapon?
5) maybe change the pick up sound to "items/itempickup.wav" (btw, why the plugin is not caching sounds from "hl2/sound/items/" dir?).
ED:
There's a little mistake in sm_ammopickup_delaydrops Cvar description:
Quote:
- Delay ammo drops until mp_freezetime has expired? 1=yes, 0=no'
Nice to see you made it. Now that we put soo much effort into those weapon ammo stocks, you don't even need them
Regarding 1) You could use the GiveAmmo method to handle the limits:
PHP Code:
/** * GiveAmmo gives ammo of a certain type to a player - duh. * * @param client The client index. * @param ammo Amount of bullets to give. Is capped at weapon's limit. * @param ammotype Type of ammo to give to player. * @param suppressSound Don't play the ammo pickup sound. * * @return Amount of bullets actually given. */ new ret = SDKCall(g_hGiveAmmo, client, 30, ammoType, true);
@Peace-Maker - I know, I didn't use that weapon ammo stock in this, but I'm going to include the much more simpler version of the ammo pickup plugin that does use that stock. This one was requested to have the ammo boxes drop so I did it a different way.
As to the limits and using the GiveAmmo (thanks btw), I'll mess around with that and check it out. I could put a CVar in so server admins can determine if they want to limit the extra rounds players can pick up to the game allowed maximum or not. The visual maximum of "extra ammo" is 999 - it rolls over after that, but doesn't max out - well, it might "max" out, but I picked up something like 1200 rounds for the m4a1 during my testing.
Thank you for the feedback - always appreciated. I might change this plugin to use the CS_GetDroppedWeaponAmmo, but SDKHooks OnWeaponDropPost is still too fast, the dropped weapon stock returns that the weapon isn't dropped... maybe I'll use a timer or other method...
Quote:
Originally Posted by GrO
Will this also block the ammo box pick up, when the max overall ammo amount is met?
Yes Also, if the ammo box has 80 rounds and the player already has 50 rounds, and the max ammo for the weapon they have holds 90 rounds, then they'll pickup 40 of the 80 and the ammo box will remain, but only have 40 rounds left.
Also, if the ammo box has 80 rounds and the player already has 50 rounds, and the max ammo for the weapon they have holds 90 rounds, then they'll pickup 40 of the 80 and the ammo box will remain, but only have 40 rounds left.
Great to hear this. What about the other points from my post, are You able to implement them?
Is it possible to not override the default limit of overall ammo count? I've noticed that You can pick up ammo boxes all the time, what exceeds the default max ammo amount for each weapon. It would be good to not allow the plugin to exceed the default max ammo amount on pick up and to not allow pick up, when max ammo limit is met.
Fixed - new CVar - sm_ammopickup_maxammo that you can use to tell the plugin to abide by max ammo if you want to use that feature. If the player doesn't pick up all of the ammo dropped, the left over ammo will remain with that ammo box model.
Issue 2
could You make so the ammo box is dropped always at the front of the player, not at random directions?
I moved it to spawn at the player's feet.
Issue 3
also the entity spawn position seems to be too high (EyePosition), what temporarily lowers the client's view position, when weapon+ammo box is dropped
I moved it to spawn at the player's feet.
Issue 4
could You make the throw power weaker, to make the ammo box land much closer to the weapon?
It will only move if the player has momentum or on a hill when the ammo drops now.
Issue 5
maybe change the pick up sound to "items/itempickup.wav" (btw, why the plugin is not caching sounds from "hl2/sound/items/" dir?).
Fixed - now the pick up sound is the itempickup.wav and it is precached
Unnumbered Issue
There's a little mistake in sm_ammopickup_delaydrops Cvar description:
Fixed - thanks
-------------------------------------
Updating OP now - if you have Updater, it should update shortly.
-------------------------------------
Version 0.2.2.2
Version 0.2.2.2 - Now requires the attached giveammo.txt gamedata file
*Fixed issues brought up by GrO and Peace-Maker (http://forums.alliedmods.net/showpos...79&postcount=2)
- special thanks to Peace-Maker for providing the giveammo gamedata and example
*Added CVar for AbideByMaxAmmo so server admins can choose how they'll handle the ammo pickup