View Single Post
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 03-04-2021 , 14:57   Re: [L4D2] Shotgun and bolt rifle fire rate and reload modification?
Reply With Quote #4

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.
__________________
Psyk0tik is offline