View Single Post
sbeve
Junior Member
Join Date: Feb 2021
Old 03-16-2021 , 23:40   Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #5

Quote:
Originally Posted by Crasher_3637 View Post
The WeaponHandling API is already pretty direct with what you want. It hooks all the functions of the player's weapon and allows users to change the speed of those functions.

You can do something like this:
PHP Code:
#include <sourcemod>
#include <WeaponHandling>

public void WH_OnReloadModifier(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier)
{
    switch (
weapontype)
    {
        case 
L4D2WeaponType_PumpshotgunL4D2WeaponType_PumpshotgunChromespeedmodifier speedmodifier 1.25// 25% faster reload
        
case L4D2WeaponType_AutoshotgunL4D2WeaponType_AutoshotgunSpasspeedmodifier speedmodifier 1.25// 25% faster reload
        
case L4D2WeaponType_HuntingRiflespeedmodifier speedmodifier 1.5// 50% faster reload
        
case L4D2WeaponType_SniperMilitaryL4D2WeaponType_SniperAwpL4D2WeaponType_SniperScoutspeedmodifier speedmodifier 1.5// 50% faster reload
    
}
}

public 
void WH_OnGetRateOfFire(int clientint weaponL4D2WeaponType weapontypefloat &speedmodifier)
{
    switch (
weapontype)
    {
        case 
L4D2WeaponType_HuntingRiflespeedmodifier speedmodifier 1.25// 25% faster fire rate
        
case L4D2WeaponType_SniperMilitaryL4D2WeaponType_SniperAwpL4D2WeaponType_SniperScoutspeedmodifier speedmodifier 1.25// 25% faster fire rate
    
}

The speed modifier is automatically applied for those two specific situations (reloading and rate of fire) so you don't have to remove the modifier "whenever anything else happens" because the WeaponHandling API takes care of all that.

You have no idea how thankful I am. I've been looking for a plugin that does exactly this (on and off, half-assedly) since 2017. I was literally writing up a request about this until I decided to take yet another look at previous post mentioning shotguns reload before submitting. The fact this this was never made before baffles me.
sbeve is offline