View Single Post
Author Message
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-16-2020 , 01:19   [L4D2] Switch Upgrade Ammo Types (1.29) [07-Nov-2023]
Reply With Quote #1

About:
  • Allows players press Shift + R to switch between Primary Ammo and Upgraded Ammo.
  • Allows players to carry both upgrade ammo types (Incendiary and Explosive).
  • Both upgrade ammo types keep with the weapon when it's dropped.
  • Upgraded ammo is carried over map transitions or restarts (only in coop/realism modes).
  • This plugin was really complicated to write (6 re-writes) due to multiple ammo bug issues with the engine.


Incompatible:
This plugin is incompatible with the following plugins:


Thanks:
  • strikeraot - For tons of testing and the idea and request.
  • Lux and MasterMind420 - For putting up with my rage while trying to figure out ammo bug issues.
  • Toranks - Spanish translation.
  • NoroHime - Chinese translations.



CVars:

Saved to l4d2_switch_ammo.cfg in your servers \left4dead\cfg\sourcemod\ folder.

PHP Code:
// 0=Plugin off, 1=Plugin on.
l4d2_switch_ammo_allow "1"

// Turn on the plugin in these game modes, separate by commas (no spaces). (Empty = all).
l4d2_switch_ammo_modes ""

// Turn off the plugin in these game modes, separate by commas (no spaces). (Empty = none).
l4d2_switch_ammo_modes_off ""

// Turn on the plugin in these game modes. 0=All, 1=Coop, 2=Survival, 4=Versus, 8=Scavenge. Add numbers together.
l4d2_switch_ammo_modes_tog "0"

// Allow swapping ammo on: 0=Neither. 1=Grenade Launcher. 2=M60. 3=Both.
l4d2_switch_ammo_guns "0"

// Display a hint when taking upgrade ammo about how to use the plugin. 0=Off. 1=Print to Chat. 2=Hint text.
l4d2_switch_ammo_hint "1"

// Which key combination to switch ammo. 1=Shift + Reload. 2=Holding Reload key.
l4d2_switch_ammo_keys "1"

// 0=Reload shotguns by emptying the clip when changing ammo types. 1=Shotguns will reload 1 bullet before the clip is full.
l4d2_switch_ammo_reload "1"

// Switch Ammo Types plugin version.
l4d2_switch_ammo_version 


Changes:
Code:
1.29 (07-Nov-2023)
    - Fixed not deleting 1 handle on plugin start.

1.28 (19-Sep-2023)
    - Fixed errors when late loading the plugin or enabling during gameplay. Thanks to "Proaxel" for reporting.

1.27 (17-Sep-2023)
    - Fixed the last update accidentally enabling unlimited usage of upgrade ammo piles and removing laser spawns. Thanks to "Proaxel" for reporting.

1.26 (05-Sep-2023)
    - Fixed the Grenade Launcher reloading in 3rd person being broken. Thanks to "Black_Wolf" for reporting.

1.25 (31-Mar-2023)
    - Fixed array out of bounds error. Thanks to "LindaFelicia" for reporting.

1.24 (19-Feb-2023)
    - Fixed errors thrown due to Special Infected being on Survivor team. Thanks to "Voevoda" for reporting.

1.23 (10-Feb-2023)
    - Fixed rare error about invalid entity. Thanks to "sonic155" for reporting.
    - Fixed "Event_WeaponFire" errors when a Special Infected is on Survivor team. Thanks to "Voevoda" for reporting.

1.22 (25-Jan-2023)
    - Plugin now listens for the "upgrade_add" command for adding upgrade ammo.

1.21 (20-Jan-2023)
    - Plugin now switches to an upgraded ammo type if available, when stock ammo is depleted. Thanks to "swiftswing1" for reporting.
    - Plugin now supports dynamic shotgun weapon clip sizes. Optionally uses Left4DHooks to detect clip size.

1.20 (06-Nov-2022)
    - Fixed invalid weapon error. Thanks to "NoroHime" for reporting.

1.19 (10-Oct-2022)
    - Now swaps ammo when holding the reload key when a clip isn't full and normal reloading has begun.

1.18 (03-Oct-2022)
    - Updated translations for holding reload key method of changing ammo.
    - Thanks to "NoroHime" for updating the Chinese translations.

1.17 (30-Sep-2022)
    - Added cvar "l4d2_switch_ammo_keys" to control the key combination for reloading.
    - Setting the cvar as "2" will allow holding Reload to change ammo. Requested by "sonic155".
    - The source contains a "MAX_TIME_KEY_HOLD" define set at 0.5 which controls how long to hold reload.

1.16 (25-Aug-2022)
    - Moved "ammo_pickup" event hook to plugin start, to prevent errors throwing about no active hook.

1.15 (19-Aug-2022)
    - Added GameData file and new feature to reload the gun when changing ammo types. Requested by "Shao".
    - Added cvar "l4d2_switch_ammo_guns" to control if the "Grenade Launcher" or "Rifle M60" ammo can be switched.
    - Changed cvar "l4d2_switch_ammo_reload" to control if shotguns should reload the whole clip or 1 round.
    - Now prevents swapping ammo until the weapon is ready to shoot.
    - Thanks to "Shao" and "Toranks" for testing.

1.14 (12-Aug-2022)
    - Added cvar "l4d2_switch_ammo_reload" to wait for reloading to finish before switch ammo type. Requested by "Shao".

1.13 (16-Jun-2022)
    - Fixed a bug where you couldn't switch to stock ammo. Thanks to "Toranks" for reporting.

1.12 (13-May-2022)
    - Fixed invalid entity error. Thanks to "sonic155" for reporting.

1.11 (02-May-2022)
    - Fixed late loading (turning the plugin off and on again) from not detecting stock ammo when upgrade ammo is equipped.
    - Fixed gaining ammo issue. Thanks to "Toranks" for reporting and testing.
    - Weapon now switches to upgrade ammo if available when no stock ammo remains.

1.10 (20-Mar-2022)
    - Added Spanish translations. Thanks to "Toranks" for providing.
    - Changes to fix warnings when compiling on SM 1.11.

1.9 (15-Sep-2021)
    - Now uses the new forward provided by "Save Weapon" plugin modified by "HarryPotter". Requires version "5.4" or newer.
    - For compatibility with both plugins to work together. Thanks to "HarryPotter" for supporting.
    - Supported plugin can be found here: https://github.com/fbef0102/L4D2-Plugins/tree/master/l4d2_ty_saveweapons

1.8 (13-Sep-2021)
    - Added support for "L4D2 coop save weapon" version by "HarryPotter".
    - Removed support for [l4d2] Save Weapon (Co-op)" plugin by "maks".
    - Changes to prevent giving upgraded ammo when someone respawns.

1.7 (12-Sep-2021)
    - Fixed not restoring map transitioned ammo on round restart. Thanks to "swiftswing1" for reporting.

1.6 (11-Sep-2021)
    - Fixed not saving ammo on map transition. Thanks to "swiftswing1" for reporting.

1.5 (30-Aug-2021)
    - Fixed the plugin breaking in modes other than coop. Thanks to "swiftswing1" for reporting and testing.

1.4 (17-Aug-2021)
    - Now automatically detects "[l4d2] Save Weapon (Co-op)" plugin by "maks" to fix giving upgrade ammo to players after map transition.

1.3 (15-Aug-2021)
    - Added cvar "l4d2_switch_ammo_hint" to display a message when taking upgrade ammo about how to use the plugin.
    - Added file "switch_ammo.phrases.txt" to display hints.
    - Fix for "[l4d2] Save Weapon (Co-op)" plugin by "maks". Thanks to "swiftswing1" for reporting.

1.2 (21-Aug-2020)
    - Fixed the last update accidentally enabling unlimited usage of upgrade ammo piles.

1.1 (18-Aug-2020)
    - Blocked the M60 and Grenade Launcher from being able to switch ammo types.

1.0 (16-Jun-2020)
    - Initial release.


Installation:
  1. Click "Get Plugin" and put the .smx file into your servers \addons\sourcemod\plugins\ folder.
  2. Download the .txt gamedata file and put into your servers \addons\sourcemod\gamedata\ folder.
  3. Download "translations.zip" and extract the "translations" folder to your servers \addons\sourcemod\ folder.

Updating from 1.16 or older:
  • New cvars have been added: use the Cvar Configs Updater, or delete the old cvars config or manually add them.

Updating from 1.17 or older:
  • New translations have been added.

Current Translations: English (en), Spanish (es), Simplified Chinese (chi), Traditional Chinese (zho).
Attached Files
File Type: txt l4d2_switch_ammo.txt (137 Bytes, 656 views)
File Type: sp Get Plugin or Get Source (l4d2_switch_ammo.sp - 301 views - 47.3 KB)
File Type: zip translations.zip (2.0 KB, 628 views)
__________________

Last edited by Silvers; 11-07-2023 at 02:38.
Silvers is offline