Raised This Month: $32 Target: $400
 8% 

[L4D2] Weapon Skin Manager (v1.0)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Qtheman
Junior Member
Join Date: Oct 2010
Plugin ID:
7338
Plugin Version:
1.0
Plugin Category:
Fun Stuff
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Randomize weapon spawn skins and allow clients to set their weapon skins via a menu. Built to be easily configurable, with fixes for various bugs and oddities.
    Old 10-16-2020 , 19:46   [L4D2] Weapon Skin Manager (v1.0)
    Reply With Quote #1

    Wow... It's been, what, almost two and a half years since I was here last? Time flies, I guess. At any rate, I'm here to present (and god I hope I'm doing this right):

    Left 4 Dead 2 - Weapon Skin Manager

    What does this plugin do?

    As of The Last Stand Update, a handful of L4D2's weapons have alternate skins. The L4D1 weapons (minus the pump shotgun) look more worn, the pump and chrome shotguns swap furniture with each other, the magnum gets a blued steel finish with a wood grip, things like that. However, this system is pretty static, by default - weapon skins aren't randomized at runtime, they have to be set by the mapper in Hammer itself. That's where this plugin comes in.
    The two most basic features provided by this plugin are simple: if enabled, it will randomize the skins of all valid weapon spawns on the map at the start of the round, and provide clients with a menu with which to select their weapon skins.
    While I was working on this plugin, Marttt released plugins of his own that fulfill the same purposes, and in most cases, there's probably not much meaningful difference between his plugins and my own here. However, I've built mine with the intention of being easily extensible - Weapon Skin Manager pulls its skin info from files in the /sourcemod/configs/ folder, meaning that server hosts can easily add or remove weapons from the list without having to recompile the plugin. If, say, you want to remove the golden crowbar skin from the menu and prevent the plugin from randomizing crowbar spawns - all you have to do is open the l4d2_wsm_meleelist.txt file, delete the line for the crowbar, and rebuild the skin list in-game. Simple as that! Clients won't see the crowbar skins in the menu, and on the next map, crowbar spawns won't have their skins randomized.

    However, that's not all this plugin does. It also fixes bugs where grenade launcher and M60 spawns don't properly skin the weapon that they give to the player, and where thrown grenades reset to the default model skin. It's also capable of managing pistol skins, so that the dual pistols a client is holding match the pistols they picked up in the world, when provided with an appropriate skin mod. Note that this doesn't refer to "RNG mods," wherein the pistol skins are randomized when the map loads - those technically don't even use alternate skins; they either select from a list of textures (it might sound pedantic, but there's a difference) or toggle transparency based on RNG. Pistol skins do have to be set up to work with this plugin, but they shouldn't be too complex.

    How it works, basically, is by taking the number of skins a single pistol has, squaring it, and using the indices of the pistol the player already has equipped and the one they've picked up to calculate which dual pistol skin should be shown. This might be easier to understand when shown in action, so here's a link to a modified version of the pistols from Lt. Rocky's Overhauling the Originals mod (provided with permission), configured to work with this plugin on its default settings. Simply set l4d2_wsm_pistols to 1 in the config file (/cfg/sourcemod/l4d2_weaponskinmanager.cfg) to see it in action. Like the rest of this plugin, it's programmed to be extensible - you can set the number of pistol skins to cycle through with a cvar, as well as toggle which pistol cycles first when two are equipped.

    Last but not least, the melee skin selection menu is compatible with the General Improvements mod from the Steam Workshop, or any other mods that move melee weapons into slot 7. I have no idea how widely used some of these features are going to be, but I wanted to make this plugin as flexible as I could.

    Having said all this, it's probably worth stating up-front: I'm not a programmer. I understand (at least some of) the principles, but I'm far from trained in the field. I'm sure my code could be much better, and that there are better ways to do some of the things I've done with this. I'm more than open to suggestions on how to improve the code, and I'll do my best to implement them.

    Features
    • Randomizes weapon spawn skins according to a list built from external text files. Supports firearms, melee weapons, and item spawns.
    • Gives clients a menu through which to set their weapons' skins. Options will only appear for weapons that have valid entries in the skin list, and if the player doesn't have any weapons with alternate skins, they'll receive a message informing them of such.
    • Fixes M60 and grenade launcher spawns not keeping their skins when picked up by a player.
    • Fixes grenades (pipe bombs, molotovs, bile jars) not keeping their skins when thrown.
    • Shows a message when the player joins a server, explaining the menu functionality to them.
    • Manages pistol skins, so that (when configured correctly) players will be able to see the pistols they've actually grabbed, instead of just seeing the skin they already had equipped.
    • Randomizes each survivor's pistol on the first map of a campaign.

    CVARS/Admin Commands

    CVARS:
    PHP Code:
    // Enable plugin functionality. Default: 1
    l4d2_wsm_enabled

    // Enable weapon spawn skin randomization. Default: 1
    l4d2_wsm_rngskins

    // Enable randomized firearm skins. Only works if l4d2_wsm_rngskins is set to 1, and requires the skin list to be reloaded if changed in-game (l4d2_wsm_reloadskins). Default: 1
    l4d2_wsm_gunskins

    // Enable randomized melee weapon skins. Only works if l4d2_wsm_rngskins is set to 1, and requires the skin list to be reloaded if changed in-game (l4d2_wsm_reloadskins). Default: 1
    l4d2_wsm_meleeskins

    // Enable randomized item skins. Only works if l4d2_wsm_rngskins is set to 1, and requires the skin list to be reloaded if changed in-game (l4d2_wsm_reloadskins). Default: 0
    l4d2_wsm_itemskins

    // Enable pistol/dual pistol skin management. Anything relating to non-magnum pistols is disabled unless this is set to 1. Default: 0
    l4d2_wsm_pistols

    // Enable grenade (molotov, pipe bomb, bile jar) skin management. Thrown grenades will always show the default skin if this is disabled. Default: 1
    l4d2_wsm_grenades

    // Enable weapon skin selection menus. Default: 1
    l4d2_wsm_skinmenu

    // Display a chat message explaining the plugin to clients after they join the game. Default: 1
    l4d2_wsm_spawnmsg

    // The mode to use for melee weapon skin handling. 0 = Secondary slot (default), 1 = Slot 7 (modded). Default: 0
    l4d2_wsm_meleemode

    // Enable randomized pistol skins per survivor at the beginning of a new campaign. Default: 0
    l4d2_wsm_startpistols

    // The number of skins each pistol has. This is NOT a 0-based index! Default: 4
    l4d2_wsm_pistolskincount

    // Which dual pistol skin calculation method to use. This should be set based on how the server's pistol skin addon is set up. If 1, the left-hand pistol cycles first, e.g.: (L1, R1), (L2, R1), (L1, R2), etc. Default: 0
    l4d2_wsm_pistolskinmode

    // How much detailed information to print to the server console. 0 = off, 1 = basic, 2 = detailed. Mainly for debugging purposes. Default: 1
    l4d2_wsm_printtoconsole 
    Admin Commands:
    PHP Code:
    // Reload the weapon/item skin list.
    sm_wsm_reloadskins

    // Reload the starting map list.
    sm_wsm_reloadmaps

    // Randomize weapon spawn skins without reloading the map.
    sm_wsm_randomize

    // Re-run code that normally only runs when a player first spawns into the game. Mainly for debugging purposes.
    sm_wsm_rehook 
    Client Commands

    PHP Code:
    // Manually select a skin for a slot's weapon. Does not work on pistols. Format: !wskin/!wsm_skin [slot] [skin]
    sm_wsm_skinsm_wskin

    // Manually select a skin for your right-hand pistol. Only works if you have a pistol (dual or singular) equipped. Format: !pistol_r/!wsm_pistol_r [skin ID]
    sm_wsm_pistol_rsm_pistol_r

    // Manually select a skin for your left-hand pistol. Only works if you have two pistols equipped. Format: !pistol_l/!wsm_pistol_l [skin ID]
    sm_wsm_pistol_lsm_pistol_l

    // Open the main skin selection menu.
    sm_wsm_menusm_skins

    // Open the pistol skin selection menu.
    sm_wsm_pistolssm_pistols 
    Installation
    1. Download the plugin and place it in your sourcemod/plugins folder.
    2. Download l4d2_wsm_translations.txt and place it in your sourcemod/translations folder.
    3. The plugin will automatically generate default lists for item/weapon skins and campaign start maps, as well as a configuration file (cfg/sourcemod/l4d2_weaponskinmanager.cfg).

    Customization

    To add a new firearm/item to the list:
    1. Open the relevant text file. All list files can be found in sourcemod/configs, beginning with l4d2_wsm.
    2. Add a new line to the text file. What you'll want to enter is the weapon/item's internal name, minus the weapon_ prefix (e.g. "rifle" for the M16, "rifle_desert" for the SCAR), followed by a semicolon, and then the total number of skins the weapon has MINUS ONE. If a weapon has three skins total - the default and two alternatives - you'll want to put 2, in other words.
    3. Save the file, and run the sm_wsm_reloadskins command from the server console or from in-game. The weapon should now be added to the skin list.

    To add a melee weapon to the list:
    1. Open the relevant text file (l4d2_wsm_meleelist.txt).
    2. Add a new line to the text file. What you'll want to enter is the melee weapon's script name (e.g. "crowbar", "baseball_bat", etc.), followed by a semicolon and the total number of skins the weapon has minus one.
    3. Save the file, and run the sm_wsm_reloadskins command.

    Note: This plugin has not been tested with custom melee weapons, but provided they meet these criteria, they should work fine:
    • The weapon model is located in the standard models/weapons/melee directory
    • The weapon model starts with the standard v_/w_ prefix
    • The weapon model shares its name with the weapon script
    So, for instance, if you have an ice axe as a melee weapon, with the script named iceaxe.txt, the model should be located at models/weapons/melee/w_iceaxe.mdl. If the model name does not match, then you should still be able to select skins from the menu, but spawns in the world won't have their skins randomized.

    To add a new starting map to the list:
    • Simply add a new line to l4d2_wsm_maplist containing the map's filename, and run the sm_wsm_reloadmaps command in-game.

    Known Bugs
    • Defibrillators don't keep their skin all the time. The paddle-less version of the model on a survivor's back always resets to the default skin when equipped. I might be able to fix this, but I dunno if my approach is going to be a particularly good one, so I've held off for now. Looking into it.

    Screenshots


    Attached Files
    File Type: sp Get Plugin or Get Source (l4d2_weaponskinmanager.sp - 1060 views - 55.1 KB)
    File Type: txt l4d2_wsm_translations.txt (6.6 KB, 536 views)
    __________________
    KyuuGryphon

    Last edited by Qtheman; 10-16-2020 at 19:46.
    Qtheman is offline
    Marttt
    Veteran Member
    Join Date: Jan 2019
    Location: Brazil
    Old 10-16-2020 , 19:57   Re: [L4D2] Weapon Skin Manager (v1.0)
    Reply With Quote #2

    Good job! As you said, I released a similar one, but I saw that you put some interesting features that I didn't thought. Thanks for sharing.
    __________________

    Last edited by Marttt; 10-16-2020 at 19:57.
    Marttt is offline
    Psyk0tik
    Veteran Member
    Join Date: May 2012
    Location: Homeless
    Old 10-16-2020 , 20:03   Re: [L4D2] Weapon Skin Manager (v1.0)
    Reply With Quote #3

    Nice job!
    __________________
    Psyk0tik is offline
    Qtheman
    Junior Member
    Join Date: Oct 2010
    Old 10-16-2020 , 20:36   Re: [L4D2] Weapon Skin Manager (v1.0)
    Reply With Quote #4

    Quote:
    Originally Posted by Marttt View Post
    Good job! As you said, I released a similar one, but I saw that you put some interesting features that I didn't thought. Thanks for sharing.
    Thank you! At first, I'd meant for this to just randomize the skins on weapon spawns when a map loaded for my own server, but as I got more comfortable with SourcePawn, it ended up growing in scope, until, well... It became this, lol.

    Come to think of it I should've given more thought to making sure I wouldn't be stepping on anyone's toes with this, heh. ^^; My apologies for that!
    __________________
    KyuuGryphon
    Qtheman is offline
    Tonblader
    Senior Member
    Join Date: Jul 2011
    Location: Peru
    Old 10-21-2020 , 19:19   Re: [L4D2] Weapon Skin Manager (v1.0)
    Reply With Quote #5

    Is it possible to include custom models and sounds (workshop, gamemaps, gamebanana, etc) to my server with this plugin?
    If so, how would i do it?

    Last edited by Tonblader; 10-21-2020 at 19:32.
    Tonblader is offline
    Qtheman
    Junior Member
    Join Date: Oct 2010
    Old 10-21-2020 , 21:28   Re: [L4D2] Weapon Skin Manager (v1.0)
    Reply With Quote #6

    For sounds, no. I'm not familiar with how sound stuff in Source (or SourceMod) works, so I'm afraid I wouldn't know where to start with implementing that.

    Models? Depends on what you're thinking, exactly. If you mean having an alternate M16 model that can appear alongside the default one, then no, unfortunately - all this plugin does is handle skin indices for the model. The thing about the pistols is that Lt. Rocky's mod has them all compiled into a single model file. Since they all share animations and the same basic shape, it works pretty well. His mod then uses RNG to toggle the transparency on the individual textures on or off, while my modified version uses regular skin indices (though in both cases it does mean that the engine's rendering every pistol like this all the time).

    If you're talking about a standard model replacement, though, you don't even need this plugin or SourceMod for that. Technically, I don't even think you'd need to have the addon on the server itself, you'd just need to have sv_pure set to 0 or 1 (someone correct me on that if I'm wrong).
    __________________
    KyuuGryphon
    Qtheman is offline
    Smoak
    Junior Member
    Join Date: Dec 2019
    Location: Maine
    Old 02-13-2021 , 22:16   Re: [L4D2] Weapon Skin Manager (v1.0)
    Reply With Quote #7

    How do I add custom skins like you did? Since I noticed the SCAR and the SPAS have unique skins that are different in the screenshots, and I kinda want to have cool stuff like that since the special skins there don't actually show up for me, the only ones that do are from the last stand update

    I feel like its important to also note that I am very dumb if I missed something here.

    Last edited by Smoak; 02-14-2021 at 01:11.
    Smoak is offline
    Darkwob
    BANNED
    Join Date: Oct 2018
    Old 06-04-2021 , 01:45   Re: [L4D2] Weapon Skin Manager (v1.0)
    Reply With Quote #8

    I don't think it would be ridiculous if I said I didn't quite understand what this plugin was doing. His main goal is to automatically open a skin menu to all players on the server who have a weapon in their hand ,and then allow them to change skin from there? If I understand correctly, is it possible that only certain flags use this feature ?
    Darkwob 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 20:07.


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