Raised This Month: $81 Target: $400
 20% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
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:
    31 
    Plugin Description:
    Allows weapons to auto fire by just holding the attack button (M1)
    Old 10-16-2020 , 20: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 - 818 views - 44.7 KB)
    __________________

    Last edited by Marttt; 02-19-2023 at 22:59.
    Marttt is offline
    Psyk0tik
    Veteran Member
    Join Date: May 2012
    Location: Homeless
    Old 10-16-2020 , 21:07   Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.0 | 16-October-2020]
    Reply With Quote #2

    Oooh sounds like an interesting plugin! Combine this with Silvers' Reload Interrupt plugin and you can have fully automated weapons with just the use of ONE button.
    __________________
    Psyk0tik is offline
    ReCreator
    Member
    Join Date: Nov 2017
    Location: Ukraine,Kyiv
    Old 10-17-2020 , 07:16   Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.0 | 16-October-2020]
    Reply With Quote #3

    Pistols starts shooting faster then m16) if it possible to make some delay it would be great)
    __________________
    Sorry for my pure English...
    ReCreator is offline
    Marttt
    Veteran Member
    Join Date: Jan 2019
    Location: Brazil
    Old 10-19-2020 , 03:43   Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.1 | 19-October-2020]
    Reply With Quote #4

    1.0.1 (19-October-2020)
    - Added new cvars to control frame delays of each weapon.
    - Nerfed the pistols shooting speed.
    __________________

    Last edited by Marttt; 11-03-2020 at 11:22.
    Marttt is offline
    KRUTIK
    Senior Member
    Join Date: Feb 2019
    Location: Мос
    Old 10-27-2020 , 02:03   Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
    Reply With Quote #5

    The plugin is super, thanks.
    KRUTIK is offline
    Lux
    Veteran Member
    Join Date: Jan 2015
    Location: Brexit
    Old 10-27-2020 , 14:42   Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
    Reply With Quote #6

    Why do you count frames?

    You should be using gametime instead of frames(tick) for auto fire, this will make it not dependent on a being a fixed tickrate.
    __________________
    Connect
    My Plugins: KlickME
    [My GitHub]

    Commission me for L4D
    Lux is offline
    Marttt
    Veteran Member
    Join Date: Jan 2019
    Location: Brazil
    Old 10-27-2020 , 15:10   Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
    Reply With Quote #7

    I had some bugs when I started using GameTime, that way it worked smoother. Thanks
    __________________

    Last edited by Marttt; 11-03-2020 at 11:23.
    Marttt is offline
    Lux
    Veteran Member
    Join Date: Jan 2015
    Location: Brexit
    Old 10-27-2020 , 16:22   Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
    Reply With Quote #8

    Here is the issue when i tested it the pistol autofire was faster on 60ticks, current method makes the convars inconsistent because of framecounting when game's tickrate is altered.

    PHP Code:
    l4d_weapon_auto_fire_pistol_frame "3"
    Translates to at default tickrate @30

    Next auto fire 
    GetGameTime + (0.033 3)

    At tickrate @60
    Next auto fire 
    GetGameTime + (0.0165 3)

    Formula
    GetGameTime 
    + (GetTickInterval 3
    If you had bugs using gametime you are using it wrong, gametime is how weapon firerates are calculated internally and nearly everything else bound to a tick.

    Edit:
    In any case you know how a tick works, I simply wanted to help you by informing you how a tick works and it's not always same tickrate you will deal with most people how no idea that it can affect plugins like this.
    __________________
    Connect
    My Plugins: KlickME
    [My GitHub]

    Commission me for L4D

    Last edited by Lux; 10-27-2020 at 17:36.
    Lux is offline
    MasterMe
    Member
    Join Date: Mar 2010
    Location: Netherlands
    Old 10-27-2020 , 19:08   Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
    Reply With Quote #9

    Quote:
    Originally Posted by Marttt View Post
    Depending on the ping, the client may experience sound and animations bugs. Pistols (Normal/Dual/Magnum) are more noticeable to this issue.
    I tested with a dedicated server on my LAN and indeed ran into this issue. But even if I change the cvar so pistols shoot pretty slow (I can click faster) there is only a sound the first time the weapon fires.

    Guessing this a client bug, thoughts?

    Edit: If this happens so consistently, maybe the server can force the client to play the pistol fire sound on from the second shot onwards?
    __________________

    Last edited by MasterMe; 10-28-2020 at 16:28.
    MasterMe is offline
    MasterMe
    Member
    Join Date: Mar 2010
    Location: Netherlands
    Old 11-02-2020 , 23:09   Re: [L4D1 & L4D2] Weapon Auto Fire [v1.0.2 | 26-October-2020]
    Reply With Quote #10

    I think this plugin is causing issues with the mounted minigun and 50cal, the behaviour when shooting those is as if you are tap firing instead of constantly firing. Guessing it needs some special handling for this, could you check?
    __________________
    MasterMe is offline
    Reply


    Thread Tools
    Display Modes

    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 17:51.


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