RSSy MYGO.pl Opublikowano Lipiec 1, 2020 o 05:03 RSSy Udostępnij Opublikowano Lipiec 1, 2020 o 05:03 Features: Allows 3rd party plugins to attach stuff to weapons 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. 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: [CS:GO/L4D1/L4D2] Weapon Charms [L4D & L4D2] Glare Known plugins this fixes (plugins that attach items to players): [L4D & L4D2] Extinguisher & Flamethrower [L4D & L4D2] Flare [L4D & L4D2] Flashlight [L4D & L4D2] Glare [L4D & L4D2] Hats Known plugins (model changers) causing attachment bugs on players: [L4D & L4D2] Character Select Menu [L4D2] Swap Character Natives and Information for developers: Spoiler Extracting Attachment Names: To support additional models for the attachment fix when changing player models. Use GCFScape or other VPK extractor to open pak01_dir.vpk etc. Extract the .mdl files you want to get the attachment points from. Use Crowbar to decompile the .mdl files to retrieve the .qc files. Put those .qc files somewhere in your server e.g. left4dead2/models/QC. Run the command sm_attachment_qc "models/QC" specifying the path to your QC folder. This will save the model attachments data to sourcemod/data/attachments_new.cfg. Merge this data with the main config attachments_api.<game>.cfg file (avoid duplicate model entries). Please post any missing models/data so others can benefit. About: This plugin creates a hidden replica of the clients weapon viewmodel and worldmodel. Only when required. This is the only way to attach entities to weapons otherwise they would be invisible. This method saves other plugins from creating multiple duplicated entities when we only need one. This method also handles fixing attachments when a clients model changes (CSM in L4D1/L4D2) to prevent extra duplicated code and wasted resources. The natives allow retrieving the entity index to attach to. The forwards allow you to change or fix your attachments. See the "Glare" and "Weapon Charms" plugins for usage examples. PHP Code: /** * Creates or retrieves the specified clients weapon worldmodel entity for attaching other entities to. * @remarks Never delete the returned entity index. Use ClearParent input on your entity instead and delete your attached entity. * * @param client Client index to affect. * @param weapon Weapon index to affect. * * @return Entity index for attachments. */ native int Attachments_GetViewModel(int client, int weapon); /** * Creates or retrieves the specified clients weapon worldmodel entity for attaching other entities to. * @remarks Never delete the returned entity index. Use ClearParent input on your entity instead and delete your attached entity. * * @param client Client index to affect. * @param weapon Weapon index to affect. * * @return Entity index for attachments. */ native int Attachments_GetWorldModel(int client, int weapon); /** * @brief Called whenever a client switches weapons * @remarks This happens after Attachments_API has changed the replica model and re-attached to the weapon. * * @param client The clients entity index * @param weapon The weapons entity index or -1 if missing * @param ent_views The ViewModel entity index or -1 if missing * @param ent_world The WorldModel entity index or -1 if missing */ forward void Attachments_OnWeaponSwitch(int client, int weapon, int ent_views, int ent_world); /** * @brief Called whenever a clients model changes (requires cvar "attachments_api_models" value "1" to enable) * * @param client The clients entity index */ forward void Attachments_OnModelChanged(int client); /** * @brief Called whenever the plugin is unloading so other plugins can delete their attachments. * */ forward void Attachments_OnPluginEnd(); /** * @brief Called whenever the plugin is late loaded so other plugins can attach their stuff. * */ forward void Attachments_OnLateLoad(); 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 "0.1" in L4D1/L4D2. "0.0" in other games (change if required, see "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 "0.1" in L4D1/L4D2. "0.0" in other games. games (change if required, see "Information for developers" for adding attachment names). // Attachments API plugin version. attachments_api_version Changes: Code: 1.0 (01-Jul-2020) - Initial release. Installation: Download the .zip and extract the files to their respective folders in your servers \addons\sourcemod\ folder. Attached Files attachments_api.zip (28.1 KB) Wyświetl pełny artykuł Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi