Raised This Month: $ Target: $400
 0% 

[ANY] Attachments API (1.17) [22-Nov-2023]


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Plugin ID:
7180
Plugin Version:
1.17
Plugin Category:
Gameplay
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    94 
    Plugin Description:
    Allows plugins to attach things to weapons. Fixes player attachments when their model changes.
    Old 07-01-2020 , 01:03   [ANY] Attachments API (1.17) [22-Nov-2023]
    Reply With Quote #1

    Features:
    • Allows 3rd party plugins to attach stuff to weapons viewmodel/worldmodel.
    • Detects when a player changes model and fixes attachments to their player model and weapons.


    About:
    • Creates hidden replicas of clients weapon worldmodel when required by other plugins, to save multiple duplicated entities and resources.
    • Fixes attachments to Weapons as required, by dropping the weapon for 0.1 seconds (set by attachments_api_equip cvar) and re-equipping.
    • Fixes attachments to player models by changing the attachment index when a players old/new model attachment name match. Checks every 0.1 seconds (set by attachments_api_check cvar)
      (currently only supports and required by L4D1 & L4D2. For example CS:GO needs data/attachments_api.csgo.cfg config data filling out if any plugins change players model, request support if required).



    Thanks:
    • "Lux" - Various ideas and code.
    • "Voevoda" - Testing and bug reports.



    Plugins using Attachment_API:

    Known plugins this fixes (plugins that attach items to players):

    Known plugins (model changers) causing attachment bugs on players:


    Natives and Information for developers:
    Spoiler




    Admin Commands: (requires "z" flag)

    PHP Code:
    sm_attachment_qc        // Parses .qc files to get model attachment names. Usage: sm_parse_qc <folder path to .qc files>. Saves to sourcemod/data/attachments_new.cfg.
    sm_attachment_reload    // Reload the attachments config: sourcemod/data/attachments_api.<game>.cfg 


    CVars:

    Saved to attachments_api.cfg in your servers \cfg\sourcemod\ folder.

    PHP Code:
    // How often to check if a players model has changed. Requires "attachments_api_models" value "1" to enable.
    attachments_api_check "0.1"

    // When weapons have attachments and a players model has changed, how long to drop the weapon before re-equipping to fix.
    attachments_api_equip "0.1"

    // 0=Off, 1=Detect when a players model changes to fix attachments to players (required by plugins attaching stuff to players).
    attachments_api_models "1" in L4D1/L4D2"0" in other games (change if requiredsee "Information for developers" for adding attachment names).

    // 0=Off, 1=Detect when a players model changes to fix attachments to weapons (required by plugins attaching stuff to weapons).
    attachments_api_weapons "1" in L4D1/L4D2"0" in other games (change if requiredsee "Information for developers" for adding attachment names).

    // Attachments API plugin version.
    attachments_api_version 


    Changes:
    Code:
    1.17 (22-Nov-2023)
        - L4D & L4D2: Fixed error when a client has no weapon. Thanks to "Krufftys Killers" for reporting.
    
    1.16 (01-Oct-2023)
        - Delayed model changed detection on player spawn to prevent attachment issues. Thanks to "little_froy" for reporting.
    
    1.15 (28-Sep-2023)
        - L4D and L4D2: Fixed dual pistols creating an extra weapon when changing player skins. Thanks to "kochiurun119" for reporting.
    
    1.14 (25-Sep-2023)
        - L4D and L4D2: Fixed invalid property errors. Thanks to "ur5efj" for reporting.
    
    1.13 (25-Sep-2023)
        - L4D and L4D2: Fixed dual pistols not carrying over on model change. Thanks to "kochiurun119" for reporting.
    
    1.12 (05-Sep-2023)
        - Fixed invalid handle error. Thanks to "Voevoda" for reporting.
    
    1.11 (31-Mar-2023)
        - Fix to detect model change on team swap. Thanks to "Voevoda" for reporting.
    
    1.10 (30-Jul-2022)
        - Changes to fix the incorrect weapon showing in OnWeaponSwitch when spawning.
        - Changes to clean up some variables on round end. Probably not required.
    
    1.9 (04-Dec-2021)
        - Changes to fix warnings when compiling on SourceMod 1.11.
        - Fixed leaking 1 handle.
    
    1.8 (27-Jun-2021)
        - Fixed and cleaned some of the plugin code.
    
        - L4D2: Updated "data/attachments_api.l4d2.cfg" to support changes from the latest update.
        - This fixes model attachment positions which otherwise was broken.
    
    1.7 (20-Apr-2021)
        - Fixed a "Client is not in game" error being thrown. Thanks to "Krufftys Killers" for reporting.
    
    1.6 (01-Oct-2020)
        - Added support for following weapons "m_nSkin" value. Fixes L4D2 new weapon skins.
        - Changes attempting to fix the "prop_dynamic_override" blocking players +USE ability. Thanks to "Lux".
    
    1.5 (25-Jul-2020)
        - Fixed picking up weapons not always triggering "Attachments_OnWeaponSwitch" (game bug).
    
    1.4 (20-Jul-2020)
        - L4D2: Added a fix for climbing ladders, plugin deletes the weapon viewmodel when climbing.
        - This ladder fix will break other plugins using the "Attachments_API" weapon viewmodel.
        - This ladder fix sends out the "Attachments_OnWeaponSwitch" forward with the weapon index -1.
        - Plugins attaching to the viewmodel should be accounting for "Attachments_OnWeaponSwitch" to -1 anyway.
        - Other games that hide weapons when climbing ladders need adding, please report if required.
    
    1.3 (11-Jul-2020)
        - Fixed not triggering weapon equip when a player dropped their last weapon and equipped the same one again.
    
    1.2 (05-Jul-2020)
        - Fixed invalid entity errors from version 1.1 update. Thanks to "Krufftys Killers" for reporting.
    
    1.1 (04-Jul-2020)
        - Changed weapon switch to detect the actual current weapon, fixes some issues where the wrong weapon was being detected.
        - Fixed weapon switch forward triggering multiple times for the same weapon.
        - Fixed "attachments_api.cfg" cvars config not being generated.
        - Removed accidental IsFakeClient line that prevented monitoring bots for changing model. Thanks to "Alex101192" for reporting.
    
    1.0 (01-Jul-2020)
        - Initial release.


    Installation:
    1. Download the .zip and extract the files to their respective folders in your servers \addons\sourcemod\ folder.
    Attached Files
    File Type: zip attachments_api.zip (34.8 KB, 487 views)
    __________________

    Last edited by Silvers; 11-22-2023 at 16:03.
    Silvers is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 07-01-2020 , 01:04   Re: [ANY] Attachments API (1.0) [01-Jul-2020]
    Reply With Quote #2

    Reserved.
    __________________

    Last edited by Silvers; 09-30-2021 at 06:21.
    Silvers is offline
    Alex101192
    Senior Member
    Join Date: Aug 2018
    Old 07-01-2020 , 05:00   Re: [ANY] Attachments API (1.0) [01-Jul-2020]
    Reply With Quote #3

    So this plugin will fix survivors' weapons not being positioned correctly after somebody changes character with csm? Or just attachments to weapons? Not sure about it.

    Last edited by Alex101192; 07-01-2020 at 05:31.
    Alex101192 is offline
    Alex101192
    Senior Member
    Join Date: Aug 2018
    Old 07-01-2020 , 05:29   Re: [ANY] Attachments API (1.0) [01-Jul-2020]
    Reply With Quote #4

    I tested this plugin very quick. The glare position is pretty much perfect. It lines up perfectly with the guns and changing characters does not break it or anything.

    However the position of the gun itself is not correct. When changing characters using csm, it becomes incorrect as it was before.
    Attached Images
    File Type: jpg zoey.jpg (70.7 KB, 677 views)
    File Type: jpg francis.jpg (52.0 KB, 572 views)

    Last edited by Alex101192; 07-01-2020 at 05:38.
    Alex101192 is offline
    SkiPlix
    Member
    Join Date: Dec 2016
    Location: Argentina
    Old 07-02-2020 , 06:53   Re: [ANY] Attachments API (1.0) [01-Jul-2020]
    Reply With Quote #5

    L4D2 Issue:
    Switching to the First aid kit/defib/ammo packs then changing thirdperson on and off,
    Creates a second model (only in first person, and barely visible with cl_viewmodelfovsurvivor 90)
    SkiPlix is offline
    Alex101192
    Senior Member
    Join Date: Aug 2018
    Old 07-02-2020 , 13:26   Re: [ANY] Attachments API (1.0) [01-Jul-2020]
    Reply With Quote #6

    I used !csc to change bots models in those pics so maybe the plugin only works with !csm and that's why the wrong weapon position seems to be happening only with csc. I didn't see any problems when players used !csm.
    Alex101192 is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 07-02-2020 , 13:30   Re: [ANY] Attachments API (1.0) [01-Jul-2020]
    Reply With Quote #7

    Quote:
    Originally Posted by SkiPlix View Post
    L4D2 Issue:
    Switching to the First aid kit/defib/ammo packs then changing thirdperson on and off,
    Creates a second model (only in first person, and barely visible with cl_viewmodelfovsurvivor 90)
    Are you using Glare or Charms or both plugins with this? Maybe a conflict with another plugin that's resetting "m_bDrawViewmodel". I don't know of an alternate method to hiding the viewmodel (SetEntityRenderMode doesn't work on viewmodels, and SetTransmit would block from the client which isn't good and causes problems with them shooting the weapon). Are you using the ThirdPersonShoulder_Detect plugin? How are you changing to 3rd person view?

    Quote:
    Originally Posted by Alex101192 View Post
    I used !csc to change bots models in those pics so maybe the plugin only works with !csm and that's why the wrong weapon position seems to be happening only with csc. I didn't see any problems when players used !csm.
    Ahh thanks for the report, I just noticed I left in the "IsFakeClient" line by accident, it's not supposed to be there so that's the reason it's failing for bots. Will update soon (you can search for "IsFakeClient", delete the line and recompile to fix).
    __________________

    Last edited by Silvers; 07-02-2020 at 13:50.
    Silvers is offline
    Alex101192
    Senior Member
    Join Date: Aug 2018
    Old 07-02-2020 , 13:41   Re: [ANY] Attachments API (1.0) [01-Jul-2020]
    Reply With Quote #8

    Quote:
    Originally Posted by Silvers View Post

    Ahh thanks for the report, I just noticed I left in the "IsFakeClient" line by accident, it's not supposed to be there so that's the reason it's failing for bots. Will update soon (you can search for "IsFakeClient", delete the line and recompile to fix).
    Ah nice. Great to see this annoying issue being fixed after 10 years. Thank you so much for your work.

    Last edited by Alex101192; 07-02-2020 at 13:46.
    Alex101192 is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 07-03-2020 , 20:05   Re: [ANY] Attachments API (1.1) [04-Jul-2020]
    Reply With Quote #9

    Updated, required for Charms/Glare plugins (and any others using this).

    Code:
    1.1 (04-Jul-2020)
        - Changed weapon switch to detect the actual current weapon, fixes some issues where the wrong weapon was being detected.
        - Fixed weapon switch forward triggering multiple times for the same weapon.
        - Fixed "attachments_api.cfg" cvars config not being generated.
        - Removed accidental IsFakeClient line that prevented monitoring bots for changing model. Thanks to "Alex101192" for reporting.
    __________________
    Silvers is offline
    Krufftys Killers
    Senior Member
    Join Date: Jan 2014
    Old 07-04-2020 , 01:13   Re: [ANY] Attachments API (1.1) [04-Jul-2020]
    Reply With Quote #10

    Getting this error
    L 07/04/2020 - 00:54:15: SourceMod error session started
    L 07/04/2020 - 00:54:15: Info (map "ch03_pripyat02") (file "C:\servers\killerrs\left4dead2\addons\source mod\logs\errors_20200704.log")
    L 07/04/2020 - 00:54:15: [SM] Exception reported: Entity -1 (-1) is invalid
    L 07/04/2020 - 00:54:15: [SM] Blaming: attachments_api.smx
    L 07/04/2020 - 00:54:15: [SM] Call stack trace:
    L 07/04/2020 - 00:54:15: [SM] [0] GetEntProp
    L 07/04/2020 - 00:54:15: [SM] [1] Line 893, C:\Servers\L4D2\left4dead2\addons\sourcemod\s cripting\attachments_api.sp::OnWeaponSwitch
    L 07/04/2020 - 01:098: Error log file session closed.
    Krufftys Killers 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 12:46.


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