This is a plugin i made for our servers to have single instances of every gun that spawns in versus instead of infinite. The reason i made it is that i didn't find anything that did what i wanted, so please let me know if there is something like that already.
I'm posting it here in case someone else has a use for it too, but also (since i'm new to this) to get some feedback from more experienced people about how to improve this plugin in any aspect and if there are possible conflicts with other plugins or the game mechanic itself,
every constructive suggestion is welcome.
Besides many others, credits to this thread especially:
http://forums.alliedmods.net/showthread.php?t=142963
The difference to already existing plugins (i found) for the same purpose is that those either remove the weapon spawn after it has been used or they set the "count" keyvalue of the weapon spawn to "1". The problem with the "count" keyvalue is that the ai director of l4d2 ignores it in competitive game modes and makes the weapon spawn an infinite supply regardless of the "count". To remove the weapon spawn after it has been used works in competitve game modes of course, but the problem with that approach is the behaviour of weapon spawns basically preventing you to drop your old weapon if it's the same as the one you pick up and some weapon spawns are even set to prevent every old gun to be dropped (like in the gun shop on map 2 of dead center).
Details
On every round start after a certain delay (10 seconds at the moment due to compatibility with other plugins that modify weapon spawns) it will replace all found gun spawns with single instances of guns. During that delay the survivor bots will be set inactive and the use button will be blocked to prevent early pickup. The survivor bots will be set inactive until only one person is still in the loading process (like after a map change), but for a maximum of 60 seconds, which is configurable since version 0.2.
Cvars
l4d_1gunspawns_version - "Version of the '[L4D & L4D2] Single Guns Spawns' plugin"
(All other cvars are
not included in version 0.1, but with those cvars left to default, version 0.1 basically behaves like version 0.2)
Code:
// Amount of guns to replace a weapon spawn with
// -
// Default: "1"
// Minimum: "1.000000"
// Maximum: "16.000000"
l4d_1gunspawns_count "1"
// Maximum time (in seconds) the survivor bots will be halted on round start
// -
// Default: "60"
// Minimum: "0.000000"
// Maximum: "900.000000"
l4d_1gunspawns_maxbothalt "60"
// Maximum number of loading clients to ignore on bot reactivation
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "32.000000"
l4d_1gunspawns_maxloading "1"
// Disable/Enable hint message while use is blocked
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
l4d_1gunspawns_message "1"
// Sum of gun types to get replaced (1: Tier 2, 2: Tier 1, 4: Magnum, 8: Pistol, 15: All)
// -
// Default: "15"
// Minimum: "0.000000"
// Maximum: "15.000000"
l4d_1gunspawns_types "15"
(automatically written (if not already existing) to ".../cfg/sourcemod/l4d_1gunspawns.cfg")
Reminder
This plugin is made for versus, but it works in all game modes at the moment, there's no game mode check yet. It's much easier to achieve what this plugin does in non-competitive game modes in a different way though.
Since all gun spawns will be single guns, you will usually only have 2 or 3 guns in the saferooms. I solved this by adding extra gun spawns to saferooms with stripper. I can upload my stripper configs aswell if there is a need for them.
Changelog
Version 0.1:
- Initial release
- Will be kept as a simple solution for default settings
Version 0.2:
- Added the possibility to set the gun types that get replaced
- Added the possibility to set the count of guns replacing a weapon spawn
- Added configuration options to turn the message while use is blocked off or on and to adjust the behaviour for reactivating the survivor bots
- Added an auto-created configuration file (".../cfg/sourcemod/l4d_1gunspawns.cfg")
- Removed checking for L4D2 weapon spawns in L4D1
I changed the naming of the plugin file and fixed the mentioned minor bug that halting the survivor bots didn't work and also added a version cvar and allowed it to run in L4D1. Besides that, version 0.1 is the same as the previous version.
For those who use the plugin for L4D1, it would be nice to get some feedback if it's working fine or not because i don't have a server set up to test it.
I hope i didn't forget to mention anything, just ask if something is not clear enough.
If you have installed the previous version named "l4d2_single_gun_spawns.smx", please delete it before installing one of the new versions, so they don't interfere.