Raised This Month: $51 Target: $400
 12% 

[L4D1 & L4D2] Weapon Auto Fire [v1.0.9 | 07-March-2021]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Plugin ID:
7337
Plugin Version:
1.0.9
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    33 
    Plugin Description:
    Allows weapons to auto fire by just holding the attack button (M1)
    Old 10-16-2020 , 19:20   [L4D1 & L4D2] Weapon Auto Fire [v1.0.9 | 07-March-2021]
    Reply With Quote #1

    Description

    This plugin allows you to continue shooting while holding the attack button (M1), like if the client was repeatedly pressing it.

    The weapons below don't have this feature by default, so if you keep holding the attack button, it does nothing:
    • All Pistols
    • All Snipers
    • Pump and Chrome Shotguns
    • Grenade Launcher

    I made it based on these plugins:

    Features
    • Allow configuring which weapons should have the auto fire turned on.
    • Allow configuring the delay in frames to auto fire.
    • Enable auto fire on weapon switch.
    • Enable auto fire after releasing a minigun/50 cal.
    • Enable auto-reload for shotguns.

    Cvars

    A configuration file named "l4d_weapon_auto_fire.cfg" will automatically be created for you upon the first run in the "\cfg\sourcemod\" folder.

    PHP Code:
    // Auto fire for Auto Shotgun.
    // Already has auto fire on vanilla.
    // Enabling makes it fire faster.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_auto_shotgun "1"

    // How many frames must wait to enable auto fire for Auto Shotgun.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "0"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_auto_shotgun_frame "0"

    // Auto fire for Dual Pistol.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_dual_pistol "1"

    // Force dual pistol fire sound to the shooter while on auto-fire.
    // Other clients aren't affected. The first shot is ignored.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_dual_pistol_force_sound "1"

    // How many frames must wait to enable auto fire for Dual Pistol.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "3"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_dual_pistol_frame "3"

    // Enable/Disable the plugin.
    // 0 = Disable, 1 = Enable.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_enable "1"

    // Auto fire for Grenade Launcher.
    // L4D2 only.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_grenade_launcher "1"

    // How many frames must wait to enable auto fire for Grenade Launcher.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "0"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_grenade_launcher_frame "0"

    // Auto fire for Hunting Rifle.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_hunting_rifle "1"

    // How many frames must wait to enable auto fire for Hunting Rifle.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "0"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_hunting_rifle_frame "0"

    // Auto fire on Machine Guns (Minigun/50cal) release.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_machine_gun_release "1"

    // Auto fire for Pistol.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_pistol "1"

    // Force pistol fire sound to the shooter while on auto-fire.
    // Other clients aren't affected. The first shot is ignored.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_pistol_force_sound "1"

    // How many frames must wait to enable auto fire for Pistol.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "3"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_pistol_frame "3"

    // Auto fire for Pistol Magnum.
    // L4D2 only.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_pistol_magnum "1"

    // How many frames must wait to enable auto fire for Pistol Magnum.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "0"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_pistol_magnum_frame "0"

    // Auto fire for Pump Shotgun.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_pump_shotgun "1"

    // How many frames must wait to enable auto fire for Pump Shotgun.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "0"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_pump_shotgun_frame "0"

    // Auto fire for Chrome Shotgun.
    // L4D2 only.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_shotgun_chrome "1"

    // How many frames must wait to enable auto fire for Chrome Shotgun.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "0"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_shotgun_chrome_frame "0"

    // Auto shotgun reload when the ammo clip is empty.
    // 0 = OFF, 1 = ON, 2 = Enable but forces full reload.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "2.000000"
    l4d_weapon_auto_fire_shotgun_reload_empty "1"

    // Auto fire for Spas Shotgun.
    // L4D2 only.
    // Already has auto fire on vanilla.
    // Enabling makes it fire faster.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_shotgun_spas "1"

    // How many frames must wait to enable auto fire for Spas Shotgun.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "0"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_shotgun_spas_frame "0"

    // Auto fire for AWP Sniper.
    // L4D2 only.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_sniper_awp "1"

    // How many frames must wait to enable auto fire for AWP Sniper.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "0"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_sniper_awp_frame "0"

    // Auto fire for Military Sniper.
    // L4D2 only.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_sniper_military "1"

    // How many frames must wait to enable auto fire for Military Sniper.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "0"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_sniper_military_frame "0"

    // Auto fire for Scout Sniper.
    // L4D2 only.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_sniper_scout "1"

    // How many frames must wait to enable auto fire for Scout Sniper.
    // 0 = Instantly on "weapon_fire".
    // -
    // Default: "0"
    // Minimum: "0.000000"
    l4d_weapon_auto_fire_sniper_scout_frame "0"

    // Auto fire on weapon switch.
    // 0 = OFF, 1 = ON.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    l4d_weapon_auto_fire_weapon_switch "1" 
    Admin Commands
    • sm_print_cvars_l4d_weapon_auto_fire => Print the plugin related cvars and their respective values to the console. (z flag required)

    Change Log

    Spoiler


    Known issues
    • Depending on the ping, the client may experience sound and animations bugs. Pistols (Normal/Dual/Magnum) are more noticeable to this issue.

    Notes
    • You can achieve a similar behavior (without plugin) by clicking fast the attack button while shooting with these weapons.
    • Frames runs approximately every 0.1 seconds on a 30 tick rate server (thanks "Lux"). If you run in a different tick rate you may have to change the "*_frame" cvar values.
    • The config is based on frames and not by gametime cause it's really hard to calculate how many milisseconds are necessary to see some changes and during my tests with gametime it reproduced inconsistent and random behaviors even with the "right" values.
    • Is possible to simulate some "lag" behaviors by using "net_fakelag <value>" in the console. I usually use a value of 100 to test.
    • Shotgun full reload may cause animation glitches cause of the client-side prediction. If you turn of the prediction (cl_predict 0) it will work more smoothy but I don't recomend cause it has some bad side-effects.
    • Auto and Spas Shotguns already do auto fire by default, but with the cvar enabled, their fire rate is increased. (increasing their respective *_frame cvars, can cancel this behavior)
    • SMGs (SMG Uzi, SMG Silenced, SMG MP5) and Rifles (M16, Desert, AK47, SG552, M60) already does auto fire in vanilla, so this plugin just ignore them.

    Understanding the frame cvars calculation (thanks "Lux")

    Code:
    Example:
    
    l4d_weapon_auto_fire_pistol_frame "3"
    
    At tickrate @30 (default):
    Next auto fire = GetGameTime + (0.033 * 3)
    
    At tickrate @60:
    Next auto fire = GetGameTime + (0.0165 * 3)
    
    Formula:
    GetGameTime + (GetTickInterval * 3)
    To Do
    • Enable auto fire for SI.
    • Enable auto fire while on shoving penalty.
    • Make dual pistols shoot at the same time.

    Thank you!

    Related Plugins

    Post Reply
    • Any feedback, bug reports, fixes, improvements, translations or suggestions for the plugin are welcome.

    Installation
    • Put the "l4d_weapon_auto_fire.smx" file (click Get Plugin) in your "\addons\sourcemod\plugins\" folder.
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d_weapon_auto_fire.sp - 982 views - 44.7 KB)
    __________________

    Last edited by Marttt; 02-19-2023 at 21:59.
    Marttt is offline
     



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 02:58.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode